2

I am making a very basic self calling form and I seem to have an error that I can't deal with.. This is the part of the page I have issues with:

<form action="" method="POST">
<div class="container 75%">
<div class="row uniform 50%">
<div class="6u 12u$(xsmall)">
<input name="email" placeholder="Email" type="text" />
</div>
<div class="6u$ 12u$(xsmall)">
<input name="pass" placeholder="Password" type="password" />
</div>
</div>
</div>
<ul class="actions">
<li><input type="submit" class="special" value="Submit" /></li>
<li><input type="reset" class="alt" value="Reset" /></li>
</ul>
</form>

</div>
</section>

<?php
if(isset($_POST['submit']))
{
//....
}
?>

The $_POST['submit'] value is undefined even if I press the submit button.

What am I doing wrong?

2 Answers 2

3

You have to give the name attribute to the submit button. Otherwise it can't be accessed using $_POST array.

<input type="submit" name = "submit" class="special" value="Submit" />
Sign up to request clarification or add additional context in comments.

Comments

0

In PHP, a variable or array element which has never been set is different from one whose value is null; attempting to access an unset value is a run time error.

You should add name="submit" because in $_POST it work like index of array which use for printing value.

<li><input type="submit" class="special" name="submit" value="Submit" /></li>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.