Jump to content

Data Not Accepted


jimfog

Recommended Posts

I want to insert some data to the database. This data comes from an html form which asks for a name and a phone. here is the form:

<form action="Proccess.php" method="post">	    <table border="0">	    <tr>	    <td>Όνομα</td>	    <td><input type="text" name="Name" maxlength="45" size="35" /></td>	    </tr>	    <tr>	    <td>Tηλέφωνο</td>	    <td><input type="text" name="Phone" maxlength="45" size="35" /></td>	    </tr>		 <tr>	   	    <td><input type="submit"  value="send" maxlength="25" size="15" /></td>	    </tr>	    </table>	    </form>'  ?>

In the proccess.php file i have entered an if statement to check if the user actually entered his details:

if(!$name||!$phone){echo 'You have not entered all the required info';exit;}

Nonetheless, even if the user enters all his/her detail i get 'You have not entered all the required info'. So, despite the user entering his details, PHP treats the situation as though he has not. What can be wrong in the above situation?

Link to comment
Share on other sites

You need to use $_POST['name'] and $_POST['phone'], not just $name and $phone.Furthermore, you should use isset() instead, like:

if (!isset($_POST['name']) || !isset($_POST['phone'])) {    echo 'You have not entered all the required info';    exit;}

Link to comment
Share on other sites

Unfortunately it does not work. I cannot understand why. here is the code, the new one: if (!isset($_POST['name']) || !isset($_POST['phone'])){echo 'Κάποια στοιχεία λείπουν';exit;} I have also tried without the isset directive. I am wondering if the problem lies in the database and in the option i have set for the specific table/fields.

Link to comment
Share on other sites

You should be aware that the name of the form elements is case sensitive with respect to how they will show up in the POST array. Compare the two. In the form you have the first letter capitalized, but not in your PHP script.

Link to comment
Share on other sites

Yes, this time the result was the desired one. Thanks. I have another problem now but this is a different post-if i do not solve on my own.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...