Reputation: 2735
I have just a basic html form within index.php which contains two text fields:
<form action="index.php" method="post">
<label for="title">Title:</label> <input type="text" size="30" name="title"/><br>
<label for="number">Number:</label> <input type="text" size="30" name="number"/><br>
<input type="submit" class="submit" name="add" value="Add"/>
</form>
Then I have some PHP script which checks if the form has been submitted, if so it runs some script however this script is never ran.
if($_POST['add'] == "Submit")
{
echo "This should print but it doesn't";
}
Any ideas why this isn't working? Thanks.
Upvotes: 2
Views: 92
Reputation: 447
The value of your submit button is "Add" but you are checking if it equals "Submit"
Try:
if($_POST['add'] == "Add")
{
echo "This should print but it doesn't";
}
Upvotes: 1
Reputation: 15338
instead of:
if($_POST['add'] == "Submit")
do:
if($_POST['add'] == "Add")
Upvotes: 6