Page 1 of 1
Undefined Index (won't go away)
Posted: Mon May 12, 2003 3:07 pm
by Templeton Peck
Notice: Undefined index: submit in C:\Program Files\Apache Group\Apache2\htdocs\test.php on line 27
which is this line if($_POST['submit'] != false)
and this is the submit its referring to:
<input type = "submit" name = 'submit' value = 'Expand'/>
any ideas why it won't work please?
Posted: Mon May 12, 2003 3:34 pm
by Coco
not meaning to hijack someone elses thread... but im having the same problem

(this is being a rather bad night for me

)
i have this:
Code: Select all
<?php
$message = str_replace("<#c_id#>",AddSlashes($id),$message);
$message = str_replace("<#c_name#>",AddSlashes($HTTP_POST_VARS['rlname']),$message);
$message = str_replace("<#c_nick#>",AddSlashes($HTTP_POST_VARS['username']),$message);
$message = str_replace("<#c_country#>",AddSlashes($countries[$HTTP_POST_VARS['country']]),$message);
$message = str_replace("<#c_icq#>",AddSlashes($HTTP_POST_VARS['icq']),$message);
$message = str_replace("<#c_email#>",AddSlashes($HTTP_POST_VARS['email']),$message);
$message = str_replace("<#c_password#>",AddSlashes($HTTP_POST_VARS['pass1']),$message);
$message = str_replace("<#c_sitename#>",$setupvars['sitename'],$message);
$message = str_replace("<#c_siteurl#>",$setupvars['siteurl'],$message);
$message = str_replace("<#c_adminemail#>",$setupvars['adminemail'],$message);
$message = str_replace("<#c_forums#>",$setupvars['forums'],$message);
$subject = "Registration confirmation For User $HTTP_POST_VARS['username']"; //******line 37
mail($HTTP_POST_VARS['email'],$subject,$message,"From:$setupvars['sitename'] <$setupvars['adminemail']>\nReplyTo:$setupvars['adminemail']");
?>
and the error is:
Notice: Undefined index: 'username' in c:\program files\apache group\apache\htdocs\stuff\lite\include\userbadconf.php on line 37
Notice: Undefined index: 'sitename' in c:\program files\apache group\apache\htdocs\stuff\lite\include\userbadconf.php on line 38
Notice: Undefined index: 'adminemail' in c:\program files\apache group\apache\htdocs\stuff\lite\include\userbadconf.php on line 38
Notice: Undefined index: 'adminemail' in c:\program files\apache group\apache\htdocs\stuff\lite\include\userbadconf.php on line 38
so hows come im getting undefined index on index's that have just been used without an error?
Posted: Mon May 12, 2003 3:43 pm
by Coco
oh and templeton.. you can always print_r($_POST) to check what you have

Posted: Mon May 12, 2003 3:58 pm
by Templeton Peck
The thing is my program works right, the way its supposed to. BUT I still get that error when I start.. once I hit that submit button once the error goes away. (if I reset it back though, there is the error again)
Posted: Mon May 12, 2003 4:06 pm
by Coco
ahh ok thats because theres no $_POST array.... so it gives a warning (which you can supress)
i suggest you might want to try changing it to
if(isset($_POST['submit']))
Posted: Mon May 12, 2003 4:14 pm
by Templeton Peck
that did the trick man! thanks appreciate it

Posted: Mon May 12, 2003 4:24 pm
by volka
Coco: You're trying to nest string literals by
$subject = "Registration confirmation For User $HTTP_POST_VARS['username']";
try
Code: Select all
$subject = "Registration confirmation For User $HTTP_POST_VARS[username]";
or
Code: Select all
$subject = 'Registration confirmation For User '. $HTTP_POST_VARS['username'];
instead
But I'm still puzzled
Code: Select all
<?php
$arr = array("'test'" => 'valid');
echo "since when is this $arr['test'] ?";
?>
I'm quite sure this gave a parse error not long ago....