Most basic form question ever?


Posted on 16th Feb 2014 07:03 pm by admin

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

No comments posted yet

Your Answer:

Login to answer
168 Like 18 Dislike
Previous forums Next forums
Other forums

New to PHP and just trying to understand a little code.
I hope I'm not annoying anyone or breaking the rules but I was wondering about this bit of code righ

Cloud Computing?
Hello,

I was wondering if anyone could help explain this term to me. I'm starting to hear it

get multiple rows
Hi I want to get multiple rows from a db

I am using this for the db query
Code: public

PHP using IF to display error
i have a MySQL query and i want to display 1 thing only if the number of affected rows is >=1

Need help with simple code, back and forward buttons.
Basically, I have a set of pages in a folder, which have the title somephrasehere_09.php, somephrase

Dynamic memory problem
Hey,

At the beginning of my code, I have this line:

Shape* gShape = 0;

url- go to webpage
i have an input text field and submit button.

how do i make the url entered into the textfiel

PHP and MySQL on intranet?
Is it possible to use both these on an intranet network?

natcasesort works on one server but not on another
Hi

I have a problem that I was hoping that someone can help me with.

I'm trying to use

a dificult string search
Hi I don't know a way around this. I want the user to input a password, but to make it a bit complca

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash