FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » Undefined index
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Undefined index [message #39876] Mon, 17 December 2007 07:42 Go to next message
ghinwoon is currently offline  ghinwoon   Malaysia
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!
Re: Undefined index [message #40554 is a reply to message #39876] Wed, 19 March 2008 06:31 Go to previous messageGo to next message
onewaylife is currently offline  onewaylife   India
Messages: 2
Registered: March 2008
Location: Bangalore
Karma: 0
Junior Member
can you show the code of your form file from where you redirected to this page..


--- onewaylife
Re: Undefined index [message #159398 is a reply to message #39876] Sat, 30 May 2009 04:36 Go to previous messageGo to next message
sarannan is currently offline  sarannan   Malaysia
Messages: 1
Registered: May 2009
Karma: 0
Junior Member
Here's an error that I am stuck with, really clueless as to why the error: Notice: Undefined index keep appearing and the line giving the problem is $_GET method or function. I created 2 simple forms. One is called myform.php and the form contains 2 input types, namely firstname and age. Another form is called action.php which prints out the name and age. The form returns error: undefined index when using $_GET["firstname"] but returns no error when using $_POST["firstname"]. Why is this so? I had tried all means to solve the error by setting register_globals = on and reinstalling the web server, mySQL and PHP but the error, undefined index still appears! I am at my wits end. Pls help. Btw, I am using IIS5.0, MySQL 4.0.14 and PHP4.3.2

Re: Undefined index [message #159399 is a reply to message #159398] Sat, 30 May 2009 06:27 Go to previous message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Try to change METHOD="POST" to METHOD="GET" in your myform.php script.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: object not found on regular webpages
Next Topic: java script to php
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 21 14:51:13 GMT 2024

Total time taken to generate the page: 0.02818 seconds