Kuba Orlik
Kuba Orlik

Reputation: 3500

Values sent to PHP via POST are all empty strings

I have the following form:

<FORM action="http://url.to.mysite.com/doc.php" method="post">
    <INPUT type="text" id="name">
    <INPUT type="text" id="id">
    <INPUT type="submit" value="Send">
    </P>
 </FORM>

Unfortunately, whatever is typed into the text fields, the PHP script receives only empty strings in every $_POST variable. All of the variables are set, just empty. What can be the cause of that?

Upvotes: 0

Views: 853

Answers (3)

petschekr
petschekr

Reputation: 1311

Only form elements with a name attribute will be sent to the PHP script (same with POST) Try this:

<form action="http://url.to.mysite.com/doc.php" method="post">
    <input type="text" id="name" name="name">
    <input type="text" id="id" name="id">
    <input type="submit" value="Send">
</form>

Upvotes: 4

Matt Whitehead
Matt Whitehead

Reputation: 1801

You need to add the name attribute to your input tags. Example: <input type="text" name="name" id="name" />

Upvotes: 3

JvdBerg
JvdBerg

Reputation: 21856

You are missing the name properties in your html:

<FORM action="http://url.to.mysite.com/doc.php" method="post">
    <INPUT type="text" name="name" id="name">
    <INPUT type="text" name="id" id="id">
    <INPUT type="submit" value="Send">
</FORM>

Upvotes: 10

Related Questions