been working hard on making a forum on my website and came across some problems with my variables for the information that I am submitting into my table. Please dont down vote me or close this because I am this question has been answered because I looked at other posts and nothing helped me. Here is my code:'
<?php include 'header.php';
$host="XXXXX"; // Host name
$username="XXXXX"; // Mysql username
$password="XXXXX"; // Mysql password
$db_name="XXXXX"; // Database name
$tbl_name="XXXXXX"; // Table name
error_reporting(E_ALL); ini_set('display_errors', 1);
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
if(isset($_GET["submit"])){
$topic=$_POST['topic'];
$detail=$_POST['detail'];
$datetime=date("d/m/y h:i:s");
}
$sql="INSERT INTO $tbl_name(topic, detail, datetime)VALUES('$topic','$detail','$datetime')";
$result=mysql_query($sql);
if($result){
echo "Successful<BR>";
echo "<a href=gen.phpView your topic</a>";
}
mysql_close()
?>
error: Notice: Undefined variable: topic in /home/XXXX/XXXX/gen.php on line 21