So I've used a script and changed it to suit my needs. The reason it doesn't work, I think, is because I'm using two tables in a database. I've got one table for user info, and then im storing comments into another database and trying to combine the two. I've got my user info in a hidden input field and I want them to be posted next to the users comment, could somebody rewrite it for me? <?php if(isset($_POST['commentonit'])) { $comment_on = $_POST['comment_on']; $comment = $_POST['comment']; $com_query = mysql_query("INSERT INTO com_system (comment_on, comment) VALUES ('$comment_on','$comment')"); if($com_query) { $referance = $_SERVER['HTTP_REFERER']; echo "Comment Inserted"; header("location: $referance"); } else { echo $commentfailure_msg; } mysql_close(); } include($_SERVER["DOCUMENT_ROOT"]."/community/herotozero/database.php"); $name = $_SESSION['username']; $query = "SELECT * from community WHERE name='$name'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $name = $row['name']; $email = $row['email']; $entity = $row['entity']; $city = $row['city']; $country = $row['country']; $website = $row['website']; $facebook = $row['facebook']; $twitter = $row['twitter']; $deviantart = $row['deviantart']; ?> <form action="" method="post"> <input type="hidden" autocomplete="on" class="required alphaspace" minlength="5" maxlength="49" id="name" name="name" readonly="readonly" value="<?=$name?>"/> <input type="hidden" name="entity" autocomplete="on" id="entity" readonly="readonly" value="<?=$entity?>"/> <input type="hidden" autocomplete="on" class="required alphaspace" minlength="2" maxlength="58" id="city" name="city" readonly="readonly" value="<?=$city?>"/> <input type="hidden" autocomplete="on" class="required alphaspace" minlength="2" maxlength="38" id="country" name="country" readonly="readonly" value="<?=$country?>"/> <input type="hidden" autocomplete="on" class="url" minlength="15" maxlength="70" id="website" name="website" readonly="readonly" value="<?=$website?>"/> <input type="hidden" autocomplete="on" class="url" minlength="15" maxlength="58" id="facebook" name="facebook" readonly="readonly" value="<?=$facebook?>"/> <input type="hidden" autocomplete="on" class="url" minlength="14" maxlength="57" id="twitter" name="twitter" readonly="readonly" value="<?=$twitter?>"/> <input type="hidden" autocomplete="on" class="url" minlength="24" maxlength="67" id="deviantart" name="deviantart" readonly="readonly" value="<?=$deviantart?>"/> <input type="hidden" name="comment_on" readonly="readonly" value="<?php echo md5($_SERVER['PHP_SELF']);?>"/> <textarea name="comment" minlength="30" maxlength="255" class="required alphaunct" id="comment">COMMENT SYSTEM IN CONSTRUCTION</textarea> Leave A Comment<br/> <input class="submit" type="submit" value="Post Comment" name="commentonit"/> </form> <?php $webpage_name = md5($_SERVER['PHP_SELF']); $com_query = mysql_query("SELECT * from com_system where comment_on='$webpage_name' ORDER BY id DESC LIMIT 0, $commentlimit"); echo "<h1>Latest Comments</h1>"; while($fetch = mysql_fetch_array($com_query)) { echo "<p>".$fetch['comment']."<br/><sub><b>Name</b>".$fetch['name']."</sub><hr /><p>"; } ?>
Yes, it's all on the same page, I only recently learned how to do this. I successfully did it with the login/registration rather than having a form page then the confirm page.