Advertisement
Guest User

Untitled

a guest
May 18th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <?php
  2. include "config.php";
  3.  
  4. $host="$mysqlhost";
  5. $username="$mysqluser";
  6. $password="$mysqlpass";
  7. $db_name="$mysqldb";
  8. $tbl_name="forum_question";
  9.  
  10. // Connect to server and select database.
  11. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  12. mysql_select_db("$db_name")or die("cannot select DB");
  13.  
  14. // get data that sent from form
  15. $topic=$_POST['topic'];
  16. $detail=$_POST['detail'];
  17. $name=$_POST['name'];
  18. $email=$_POST['email'];
  19.  
  20. $datetime=date("d/m/y h:i:s"); //create date time
  21.  
  22. $sql="INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')";
  23. $result=mysql_query($sql);
  24.  
  25. if($result){
  26. echo "Successful<BR>";
  27. echo "<a href=main_forum.php>View your topic</a>";
  28. }
  29. else {
  30. echo "ERROR";
  31. }
  32. mysql_close();
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement