Well, some of us would like to know some stuff about postdata to help with script creation.. So I made this nice little tutorial.
The first thing with postdata, you need to make the field. There 2 things to keep in mind when making the field. 1) The name of the field, and 2) The kind of field. (Text, password, radio.. etc.).
So, this is how a basic form goes, This covers passwords, radio buttons, and fields. I might add in dropdown at a later time. Here (uses php in parts, this is in the document):
(The spaces after the opening of the tag are there to prevent phrasing)
< form method="post" action="< ?echo $_SERVER[‘PHP_SELF’]; ?>“>
Password - < input type="password" id="password" name="password" />
Text - < input type="text" id="text" name="text" />
Radio - < input type="radio" value="1" id="radio" name="radio" />
Submit - < input type="submit" value="Submit" id="submit" name="submitted" />
< /form>
(Note, Radio and submit both need value=”".)
Now, what are we gona do with this postdata? Well, For demo purposes we’ll simply display them.
Now, the name=”" in the html is the post name, so if it’s defined name=”password”, then it’s $_POST[’password’]. This IS case sensitive.
So, php code for this is:
(The spaces after the opening of the tag are there to prevent phrasing)
< ?
$submitted = $_POST[’submitted’];
// Is the “submitted” data coming in? If so, do this:
if ($submitted){
$password = $_POST[‘password’];
$text = $_POST[‘text’];
$radio = $_POST[‘radio’];
echo $password.“< br /> “.$text.“< br /> “.$radio;< br /> }
//If submitted isn’t defined… do this:
elseif(!$submitted){
//(We end php and start html because echo(); and print(); use php processor, not a LOT, but it’s not a good habit to get into.)
?>
< form action="< ?echo $_SERVER[‘PHP_SELF’]; ?>” method=”post”>
Password - < input type="password" id="password" name="password" />
Text - < input type="text" id="text" name="text" />
Radio - < input type="radio" value="1" id="radio" name="radio" />
Submit - < input type="submit" value="Submit" id="submit" name="submitted" />
< /form>
< ?
}
?>
Well, I guess that’s it for now, If you want another tutorial drop a comment in here