-1

I am trying to collect data from the user in a form and display the data back to them.

I am using WAMP.

Here is my html code

<FORM METHOD="POST" ACTION="submit.php">
<INPUT type="text" name="URL" size=17 value="http://">
<INPUT type="text" name="user" size=17>
<INPUT type="text" name="email" size=17>
<INPUT type="submit" value="Submit" name="submit"/>
<INPUT type=reset value="Clear">
</form>

Here is my submit.php code:

<?php 
if (isset($_POST['URL'])){
    echo "set";
}
else
{ 
    echo "not set";  
}
?>

When I execute this, I am always getting "not set" as the output.

3
  • 5
    $_POST, not $POST Commented Mar 27, 2014 at 10:13
  • There is a big difference in writing $POST and $_POST. $_POST is a superglobal variable. Commented Mar 27, 2014 at 10:16
  • its not working for $_POST also . Commented Mar 27, 2014 at 10:29

3 Answers 3

1

It should be $_POST not $post, so your code should be :-

<?php 
if (isset($_POST['URL'])){
    echo "set";
}
else
{ 
    echo "not set";  
}
?>

Also your form tag should not contain encytype="text/plain" because PHP doesn't handle it (and it is not a bug)

Valid values for enctype in <form> tag are:

application/x-www-form-urlencoded
multipart/form-data

So remove encytype="text/plain"

Sign up to request clarification or add additional context in comments.

Comments

0
<?php 
if (isset($_POST))
{ 
    echo "set"; 
}
else
{
    echo "not set";
}
 ?>

try this

Comments

0

Remove ENCTYPE="text/plain"

from the form

So the form should look like

<form method="POST" action="submit.php">

And its $_POST not $POST

if (isset($POST['URL'])){

should be

if (isset($_POST['URL'])){

Here is an example of handling the form

<?php
if(isset($_POST["submit"])){
    if (isset($_POST['URL']) && $_POST['URL'] != ''){
            echo "set";
    }
    else
    { 
            echo "not set";  
    }
}
?>


<FORM METHOD="POST" ACTION="submit.php" >
<INPUT type="text" name="URL" size=17 value="http://">
<INPUT type="text" name="user" size=17>
<INPUT type="text" name="email" size=17>
<INPUT type="submit" value="Submit" name="submit"/>
<INPUT type=reset value="Clear">
</form>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.