Guest User

Untitled

a guest
Apr 25th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. <?php
  2.  
  3. $server = "localhost";
  4. $user = "isonuZ";
  5. $pass = "150NuZ!";
  6. $db = "test";
  7. $tb_name = "guestbook";
  8. $connection = mysql_connect($server, $user, $pass) or die(mysql_error());
  9. @mysql_select_db($db);
  10.  
  11. function validation($var) {
  12. if(isset($_POST[$var])){
  13. return $_POST[$var];
  14. } else {
  15. die("Didn't work");
  16. }
  17. }
  18.  
  19. $name = validation("name"); //textbox must be named 'name'
  20. $email = validation("email"); //textbox must be named email
  21. $comment = validation("comment"); //textbox must be named comment
  22. $datetime = date("y-m-d h:i:s"); //date-time
  23. $query = "INSERT INTO '{$tb_name}'(name, email, comment, datatime) VALUES('{$name}', '{$email}', '{$comment}', '{$datetime}')";
  24. $result = mysql_query($query) or die(mysql_error());
  25.  
  26. if($result) {
  27. echo "Everything went better than expected!<br /><a href=\"viewguestbook.php\">Dude, you should totally view the guestbook now!</a>";
  28. } else {
  29. echo "Something went wrong...";
  30. }
  31.  
  32. mysql_close();
  33.  
  34. ?>
Add Comment
Please, Sign In to add comment