PHP Forum

Most basic form question ever?

Hello,

I want to use this snippet to make sure the fields in a form are ok before processing it.

Code: <FORM method="post">
To:

<input type="text" name="name" size="40" value="<?php if($name) { print $name; } else { print "Insert Name"; } ?>">

<input name="action" type="submit" value="Update Form">

</FORM>

It works, but I don't understand why.

The if statement is checking for the variable $name, but I haven't used the code that I would normally use.

What I see in all my tutorials would lead me to use...

$name= $_POST['name];

So, I'm confused as to where the $name variable is being found.

Thanks for your patience
Advertisement

0 answers

No answers posted yet. Be the first to answer.

Your answer

Login to answer

Trending today: see what people are reading