Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #(add_topic.php)
- <?php
- $host="mysql.webcindario.com"; // Host name
- $username="myforum"; // Mysql username
- $password="......."; // Mysql password
- $db_name="myforum"; // Database name
- $tbl_name="forum_question"; // Table name
- // Connect to server and select database.
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- // get data that sent from form
- $topic=$_POST['topic'];
- $detail=$_POST['detail'];
- $name=$_POST['name'];
- $email=$_POST['email'];
- $datetime=date("d/m/y h:i:s"); //create date time
- $sql="INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')";
- $result=mysql_query($sql);
- if($result){
- echo "Successful<BR>";
- echo "<a href=main_forum.php>View your topic</a>";
- }
- else {
- echo "ERROR";
- }
- mysql_close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement