Reputation: 2173
So I have a sign up form, and there is some PHP at the top of the code. It gives me this error:
Notice: Undefined index: register in /home/content/04/7195304/html/index.php on line 20
This is line 20:
if ($_POST['register']) {
Here is the submit button:
<input type="submit" class="gobutton" value="Register" name="register"/>
Edit
So here's my form tags:
<form action="index.php" method="POST">
Upvotes: 1
Views: 14955
Reputation: 4467
Is your form using method="GET" instead of method="POST"?
You can also add addition checks to make sure the index exists, like this:
if (isset($_POST['register'])) {
// do stuff
}
You can also debug the form submission like this:
var_dump($_POST);
Upvotes: 2
Reputation: 2611
You should check it like this:
if ( isset($_POST['register']) ) {}
to avoid getting notice.
Upvotes: 8