Jump to content

Undefined index?


Guest

Recommended Posts

I've done this before and I've never gotten this notice, why am I getting it now?

 

<p>
<center><form method = "post" action = "">
		<input type = "text" name = "name">
		<input type = "password" name = "pass">
		<input type = "submit" name = "submit">
		</form>
</center> 
</p>
    ';

if($_POST['submit']){
	echo"blah";
}

Notice: Undefined index: submit

 

 

Link to comment
https://forums.phpfreaks.com/topic/228573-undefined-index/
Share on other sites

Submit the form and then see if you still get the notice. (I'm pretty sure you won't)

 

All it's doing is telling you that a form hasn't been submitted, $_POST['submit'] doesn't exist, which, for the first time the page is loaded, will certainly be the case. Once the form is submitted and the page is reloaded, $_POST['submit'] will exist, you won't get the notice, and your if statement will run.

 

Denno

Link to comment
https://forums.phpfreaks.com/topic/228573-undefined-index/#findComment-1178535
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.