Jump to content

chandler

Members
  • Posts

    142
  • Joined

  • Last visited

Everything posted by chandler

  1. I added the column name myself, for the name of the person leaving the comment.
  2. Made some changes to comment script, giving error "Column count doesn't match value count at row 1" all columns in the db seem to be getting the data accept for comment. <?php require_once('config.php'); if (isset($_POST['comment'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { function make_safe($variable) { $variable = mysql_real_escape_string(trim($variable)); return $variable; } $name = make_safe($_POST['name']); $comment = make_safe($_POST['comment']); ini_set('date.timezone', 'Europe/London'); // Insert a row of information into the table "example" mysql_query("INSERT INTO comments (name, comment, date_added) VALUES('$name', '$comment' '$date_added' ) ") or die(mysql_error()); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="name"><br /> <label><span class="required">*</span> Message: </label> <textarea name="comment" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php // Retrieve all the data from the "example" table $result = mysql_query("SELECT `comment`, comment_id, date_added FROM comments c JOIN pages p ON p.page_id = c.page_id WHERE c.page_id = 1 ORDER BY c.date_added") or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { $name = $row['name']; $comment = $row['comment']; $date_added = $row['date_added']; $name = stripslashes($name); $comment = stripslashes($comment); // Print out the contents of the entry echo "<div id=\"census41_messages\">"; echo "<div id=\"comments_box\"><div id=\"comment_name\"><p>$name<em> Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$comment</p></div>"; echo "</div>"; } ?>
  3. Hmm, I must be doing something very wrong, nothing is working. its so frustrating comment script: <?php require_once('config.php'); if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { function make_safe($variable) { $variable = mysql_real_escape_string(trim($variable)); return $variable; } $name = make_safe($_POST['name']); $comment = make_safe($_POST['comment']); // Insert a row of information into the table "example" mysql_query("INSERT INTO comments (name, comment) VALUES('$name', '$comment') ") or die(mysql_error()); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="name"><br /> <label><span class="required">*</span> Message: </label> <textarea name="comment" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php ini_set('date.timezone', 'Europe/London'); // Retrieve all the data from the "example" table $result = mysql_query("SELECT `comment`, comment_id, date_added FROM comments c JOIN pages p ON p.page_id = c.page_id WHERE c.page_id = 1 ORDER BY c.date_added") or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { $name = $row['name']; $comment = $row['comment']; $name = stripslashes($name); $comment = stripslashes($comment); // Print out the contents of the entry echo "<div id=\"census41_messages\">"; echo "<div id=\"comments_box\"><div id=\"comment_name\"><p>$name<em> Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$comment</p></div>"; echo "</div>"; } ?> main page where last 5 comments are displayed: <?php require_once('config.php'); // Retrieve all the data from the "example" table $result = mysql_query("SELECT `comment`, comment_id, date_added FROM comments c JOIN pages p ON p.page_id = c.page_id WHERE c.page_id = 1 ORDER BY c.date_added") or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { $name = $row['name']; $comment = $row['comment']; $name = stripslashes($name); $comment = stripslashes($comment); ini_set('date.timezone', 'Europe/London'); // Print out the contents of the entry echo "<div id=\"census41_messages_index\">"; echo "<div id=\"comments_box_index\"><div id=\"comment_name\"><p>$name<em> Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$comment</p></div>"; echo "</div>"; } ?> Thanks for your help TeNDoLLA
  4. Wow sounds complicated, but I think I understand what you mean.
  5. Hi I have made this comment script from reading a few tut's, it started off using a text file, then I was advised to switch to using MySQL db. I am completely rubbish at both PHP/MySQL and I am stuck on a few things could some one help me along with a few problems. problem #1 The date and time system is echoing out the current time, how do I get this to show the date/time the comment was made? problem #2 In the index.php (main page) I am showing the last 5 comments made from a number of pages, I have made a new table in the db, page_id, page_name, and page_url, in each of the 5 comments on the index.php (main page) I would like a link to the relevant page that the comment was made on. If you can give some tips on how to accomplish this please. Here is the script <?php require_once('config.php'); if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { function make_safe($variable) { $variable = mysql_real_escape_string(trim($variable)); return $variable; } $name = make_safe($_POST['name']); $message = make_safe($_POST['message']); // Insert a row of information into the table "example" mysql_query("INSERT INTO comments (name, message) VALUES('$name', '$message' ) ") or die(mysql_error()); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="name"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php ini_set('date.timezone', 'Europe/London'); // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM comments ORDER BY id DESC") or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { $name = $row['name']; $message = $row['message']; $name = stripslashes($name); $message = stripslashes($message); // Print out the contents of the entry echo "<div id=\"census41_messages\">"; echo "<div id=\"comments_box\"><div id=\"comment_name\"><p>$name<em> Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message</p></div>"; echo "</div>"; } ?> Thanks for all your help, much appreciated!
  6. I have a problem with the date and time, it's echoing out the current time on each comment, do I need to put date and time into the db column too? or is there another way? <?php require_once('config.php'); if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { function make_safe($variable) { $variable = mysql_real_escape_string(trim($variable)); return $variable; } $name = make_safe($_POST['name']); $message = make_safe($_POST['message']); // Insert a row of information into the table "example" mysql_query("INSERT INTO comments (name, message) VALUES('$name', '$message' ) ") or die(mysql_error()); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="name"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php ini_set('date.timezone', 'Europe/London'); // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM comments ORDER BY id DESC") or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { $name = $row['name']; $message = $row['message']; $name = stripslashes($name); $message = stripslashes($message); // Print out the contents of the entry echo "<div id=\"census41_messages\">"; echo "<div id=\"comments_box\"><div id=\"comment_name\"><p>$name<em> Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message</p></div>"; echo "</div>"; } ?> thanks
  7. Hi again, with the new mysql table should I have a column for the url or is that not needed? if so what datatype should be used for url's, will MEDIUMBLOB work? like this? // Create a MySQL table in the selected database mysql_query("CREATE TABLE pages( page_id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), page_name VARCHAR(30), url MEDIUMBLOB)") or die(mysql_error()); echo "Table Created!"; I have been looking on google however I'm not finding any examples for this.
  8. I see it now FIXED
  9. Hi, I was changing the column names like you suggested, I don't see any mistakes in the code but I am not getting the message displayed, I am only getting the name displayed in the name field and in the comments field. can you see where its gone wrong? <?php require_once('config.php'); if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { // Create a MySQL table in the selected database mysql_query("CREATE TABLE comments( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), message MEDIUMBLOB)") or die(mysql_error()); echo "Table Created!"; ini_set('date.timezone', 'Europe/London'); function make_safe($variable) { $variable = mysql_real_escape_string(trim($variable)); return $variable; } $name = make_safe($_POST['name']); $message = make_safe($_POST['message']); // Insert a row of information into the table "example" mysql_query("INSERT INTO comments (name, message) VALUES('$name', '$message' ) ") or die(mysql_error()); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="name"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM comments ORDER BY id DESC") or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { $message = $row['name']; $message2 = $row['message']; $message = stripslashes($name); $message2 = stripslashes($message); // Print out the contents of the entry echo "<div id=\"census41_messages\">"; echo "<div id=\"comments_box\"><div id=\"comment_name\"><p>$name<em> Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message</p></div>"; echo "</div>"; } ?> Thanks
  10. ok thanks, I will do some reading on this today.
  11. would I create a new table for this, I am trying to add a column with page_id AUTO_INCREMENT, but I keep getting errors as there is already a column with AUTO_INCREMENT. error msg: "there can be only one auto column and it must be defined as a key " Like I said I am new to all this and its a bit confusing. Thanks again for you help
  12. how would I get the page id, is there a tut around or some thing in the manual referring to this?
  13. I only have the columns id, message, message2..do I need to add another column? if so does it matter what its called or what data type it is, I am new to all this.
  14. Hello again The subject may be wrong I am not sure of the technical term. I have a comment script on several pages, and on the main index.php I have the last 5 updated comments from those pages. How can I tell from what page a comment was made, I want to have a link for the user, to take them to the page. For example: The last 5 comment: Name: Mr Jones Message: Bla bla bla <a href="page3.php "> read more</a> comment code: <?php require_once('config.php'); if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { ini_set('date.timezone', 'Europe/London'); function make_safe($variable) { $variable = mysql_real_escape_string(trim($variable)); return $variable; } $message = make_safe($_POST['message']); $message2 = make_safe($_POST['message2']); // Insert a row of information into the table "example" mysql_query("INSERT INTO comments (message, message2) VALUES('$message', '$message2' ) ") or die(mysql_error()); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="message"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message2" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM comments ORDER BY id DESC") or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { $message = $row['message']; $message2 = $row['message2']; $message = stripslashes($message); $message2 = stripslashes($message2); // Print out the contents of the entry echo "<div id=\"census41_messages\">"; echo "<div id=\"comments_box\"><div id=\"comment_name\"><p>$message<em> Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message2</p></div>"; echo "</div>"; } ?> last 5 comments made code (index.php): <?php require_once('config.php'); // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM comments ORDER BY id DESC LIMIT 5") or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { $message = $row['message']; $message2 = $row['message2']; $message = stripslashes($message); $message2 = stripslashes($message2); // Print out the contents of the entry echo "<div id=\"census41_messages_index\">"; echo "<div id=\"comments_box_index\"><div id=\"comment_name\"><p>$message<em> Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message2</p></div>"; echo "</div>"; } ?> Many Thanks for your help.
  15. All seems to be working fine here is the end result. <?php require_once('config.php'); if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { ini_set('date.timezone', 'Europe/London'); function make_safe($variable) { $variable = mysql_real_escape_string(trim($variable)); return $variable; } $message = make_safe($_POST['message']); $message2 = make_safe($_POST['message2']); // Insert a row of information into the table "example" mysql_query("INSERT INTO comments (message, message2) VALUES('$message', '$message2' ) ") or die(mysql_error()); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="message"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message2" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM comments ORDER BY id DESC") or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { $message = $row['message']; $message2 = $row['message2']; $message = stripslashes($message); $message2 = stripslashes($message2); // Print out the contents of the entry echo "<div id=\"census41_messages\">"; echo "<div id=\"comments_box\"><div id=\"comment_name\"><p>$message<em> Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message2</p></div>"; echo "</div>"; } ?> Many thanks for all your help.
  16. Yes I think so, the db is set up like so The ID = id int(11) auto_increment The Name = message varchar(50) latin1_general_ci The comments = message2 mediumblob BINARY - is that ok? How do I strip the slashes to stop this ( that's - that\'s) Thanks
  17. Ok I changed the loop, works nice. Fixed the CSS to get rid of the spaces. how do I get the last comment to show on top? thank you all for your help. while($row = mysql_fetch_assoc( $result )) { $message = $row['message']; $message2 = $row['message2']; // Print out the contents of the entry echo "<div id=\"census41_messages\">"; echo "<div id=\"comments_box\"><div id=\"comment_name\"><p>$message<em>Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message2</p></div>"; echo "</div>"; }
  18. Yes in the end I think it made more sense to use the db. I have fixed the duplicate entries, a lot of guess work. problems: #1 $message = stripslashes($_POST['message']); This don't work any more, is there another way to do this when using database? Is this right? I'm not getting any errors from it. #2 function make_safe($variable) { $variable = mysql_real_escape_string(trim($variable)); return $variable; } $message = make_safe($_POST['message']); $message2 = make_safe($_POST['message2']); $check = mysql_query("SELECT message, message2, UserLevel FROM Users WHERE Username = '".$message."' and message2 = '".$message2."'"); <?php require_once('config.php'); if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { $message = htmlentities($_POST['message']); $message2 = htmlentities($_POST['message2']); $message = stripslashes($_POST['message']); $message2 = stripslashes($_POST['message2']); ini_set('date.timezone', 'Europe/London'); function make_safe($variable) { $variable = mysql_real_escape_string(trim($variable)); return $variable; } $message = make_safe($_POST['message']); $message2 = make_safe($_POST['message2']); $check = mysql_query("SELECT message, message2, UserLevel FROM Users WHERE Username = '".$message."' and message2 = '".$message2."'"); // Insert a row of information into the table "example" mysql_query("INSERT INTO comments (message, message2) VALUES('$message', '$message2' ) ") or die(mysql_error()); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="message"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message2" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM comments") or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { // Print out the contents of the entry echo "<div id=\"census41_messages\">"; echo "<div id=\"comments_box\">"; echo "<div id=\"comment_name\">".$row['message']." <em>Says:</em></div>"; echo "<div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />".$row['message2']; echo "</div>"; echo "</div>"; } ?> Thank you.
  19. after doing "TRUNCATE TABLE comments" all the comments were removed, but I am still getting the duplicated comment and the space. I guess this so I am sure it got something to do with this, do I need .$row ? if so how do I do that I did try kept giving errors echo "<div id=\"comments_box\"><div id=\"comment_name\"><p>$message<em>Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message2</p></div>";
  20. Hi thanks for that, I was just looking that up, my problems now are the same message is repeated and there is a huge space between the messages can you see from the code why its doing this? Thanks here is the new code <?php require_once('config.php'); if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { $message = htmlentities($_POST['message']); $message2 = htmlentities($_POST['message2']); $message = stripslashes($_POST['message']); $message2 = stripslashes($_POST['message2']); ini_set('date.timezone', 'Europe/London'); // Insert a row of information into the table "example" mysql_query("INSERT INTO comments (message, message2) VALUES('$message', '$message2' ) ") or die(mysql_error()); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="message"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message2" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM comments") or die(mysql_error()); // store the record of the "example" table into $row while($row = mysql_fetch_assoc( $result )) { // Print out the contents of the entry echo "<div id=\"census41_messages\">"; echo "<div id=\"comments_box\"><div id=\"comment_name\"><p>$message<em>Says: </em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message2</p></div>"; echo "</div>"; } ?>
  21. I think I am close but can some one look this over, I'm not getting all the data from the db, I get the comment but no name?, and I am unsure if the data is coming from the db or the txt file. also I have lost all the css now how do I get that back? here is the code <?php require_once('config.php'); if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { $message = htmlentities($_POST['message']); $message2 = htmlentities($_POST['message2']); $message = stripslashes($_POST['message']); $message2 = stripslashes($_POST['message2']); ini_set('date.timezone', 'Europe/London'); // add the newest comment to the start of the file $comments = "<div id=\"comments_box\"><div id=\"comment_name\"><p>$message <em>Says:</em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message2</p></div>"; // this is the new comment to be added $comments .= file_get_contents('messages.txt'); // now we get all the existing comments and append it to the $comments variable. // Insert a row of information into the table "example" mysql_query("INSERT INTO comments (message, message2) VALUES('$message', '$message2' ) ") or die(mysql_error()); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="message"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message2" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM comments") or die(mysql_error()); // store the record of the "example" table into $row $row = mysql_fetch_array( $result ); // Print out the contents of the entry echo "<div id=\"census41_messages\">"; echo "Name: ".$row['mesaage']; echo "Message: ".$row['message2']; echo "</div>"; ?> Thanks
  22. Ok I have made the table, // Create a MySQL table in the selected database mysql_query("CREATE TABLE comments( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30))") or die(mysql_error()); echo "Table Created!"; Should I see any rows / columns id, names etc, cos at the moment I only see table comments without any option to browse it. the complete code is, I know I have to remove some of the old code if any one can show me what I should remove it would be a big help ..thanks <?php require_once('config.php'); if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { $message = htmlentities($_POST['message']); $message2 = htmlentities($_POST['message2']); $message = stripslashes($_POST['message']); $message2 = stripslashes($_POST['message2']); ini_set('date.timezone', 'Europe/London'); // add the newest comment to the start of the file $comments = "<div id=\"comments_box\"><div id=\"comment_name\"><p>$message <em>Says:</em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message2</p></div>"; // this is the new comment to be added $comments .= file_get_contents('messages.txt'); // now we get all the existing comments and append it to the $comments variable. // Create a MySQL table in the selected database mysql_query("CREATE TABLE comments( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30))") or die(mysql_error()); echo "Table Created!"; // write all the comments back to the file with the newest comment first $fp = fopen('messages.txt', 'w'); fwrite($fp, $comments); fclose($fp); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="message"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message2" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php echo "<div id=\"census41_messages\">"; readfile ('messages.txt'); echo "</div>"; ?>
  23. Ok I have read that, I am going to give it a go and see what mess I can make of this brb.
  24. This is what I have so far, how do I put the data into the db and also display it? <?php require_once('config.php'); if (isset($_POST['message'])) { if (isset($_SESSION['token']) && $_POST['token'] == $_SESSION['token']) { $message = htmlentities($_POST['message']); $message2 = htmlentities($_POST['message2']); $message = stripslashes($_POST['message']); $message2 = stripslashes($_POST['message2']); ini_set('date.timezone', 'Europe/London'); // add the newest comment to the start of the file $comments = "<div id=\"comments_box\"><div id=\"comment_name\"><p>$message <em>Says:</em></div><div id=\"comment_date\">" . date ("D, M d, Y, g:i a") . "</div><br />$message2</p></div>"; // this is the new comment to be added $comments .= file_get_contents('messages.txt'); // now we get all the existing comments and append it to the $comments variable. // write all the comments back to the file with the newest comment first $fp = fopen('messages.txt', 'w'); fwrite($fp, $comments); fclose($fp); } } $token = md5(uniqid(rand(), true)); $_SESSION['token'] = $token; ?> <form id="contFrm" method="POST"> <input type="hidden" name="token" value="<?php echo $token;?>" /> <label><span class="required">*</span> Full Name:</label> <input type="text" class="box" name="message"><br /> <label><span class="required">*</span> Message: </label> <textarea name="message2" id="message" cols="25" rows="8"></textarea><br /> <input type="submit" class="button" value="Submit"> </form> <?php echo "<div id=\"census41_messages\">"; readfile ('messages.txt'); echo "</div>"; ?> Thank You
  25. Ok that is setup and seems to be working fine.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.