Advertisement
Guest User

Untitled

a guest
May 10th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #(add_topic.php)
  2.  
  3. <?php
  4. $host="mysql.webcindario.com"; // Host name
  5. $username="myforum"; // Mysql username
  6. $password="......."; // Mysql password
  7. $db_name="myforum"; // Database name
  8. $tbl_name="forum_question"; // Table name
  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