Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host="localhost"; // Host name
- $username=""; // Mysql username
- $password=""; // Mysql password
- $db_name="test"; // 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 = htmlspecialchars(mysql_real_escape_string($_POST['topic']));
- $detail = htmlspecialchars(mysql_real_escape_string($_POST['detail']));
- $name = htmlspecialchars(mysql_real_escape_string($_POST['name']));
- $email = htmlspecialchars(mysql_real_escape_string($_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)
- {
- print <<<HTML
- Successful<BR>
- <a href=main_forum.php>View your topic</a>
- HTML;
- }
- elseif(!$result)
- {
- print "Error ";
- }
- mysql_close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement