Undefined index [message #39876] |
Mon, 17 December 2007 07:42 |
ghinwoon
Messages: 1 Registered: December 2007 Location: Malyasia
Karma: 0
|
Junior Member |
|
|
Hi, i m new to php. I get an UNDEFINED INDEX error message that reads: Notice:Undefined index: topic in ....on line 12
Notice: Undefined index: detail in ....on line 13
Notice: Undefined index: name in ....on line 14
Notice: Undefined index: email in ... on line 15
Here is my code
<?php
$host="localhost";
$username="root";
$password="";
$db_name="test";
$tbl_name="forum_question";
// 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");
$topic=$_POST['topic'];
$detail=$_POST['detail'];
$name=$_POST['name'];
$email=$_POST['email'];
$datetime=date("d/m/y h:i:s");
$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();
?>
$topic=$_POST['topic'];
$detail=$_POST['detail'];
$name=$_POST['name'];
$email=$_POST['email'];is at line 12,13,14,15
can anyone tell me how to correct it, plz....
thanks!
|
|
|
|
|
|