Category: php
Visual example of how PHP handles the super-global array variable "$_POST"
Versions and Skill Level
- PHP Version - PHP 5x
- Reader skill level - Beginner
- XHTML 1.0 Transitional - interchangeable with HTML 4.0
Imagine that an array-name like the one I am using here, "$_POST," is a bookcase. On this bookcase there is the possibility for one or more shelves to be built. Each shelf will have the same name of whatever we store on it. How many shelves we build and what we name them depends on what we call the stuff, how much stuff we need to store, and how we go about storing it.
Now lets say that what we want to store is a miniature bookcase labeled "$first_name." In this instance we know that our miniature bookcase has five shelves labeled 0 - 4, from top to bottom.
- Shelf number 0 has a trinket shaped like the small letter "a" stored on it.
- Shelf number 1 has a trinket shaped like the small letter "b" stored on it
- Shelves 2 through 4 have c, d, and e respectively.
Notice that $_POST is an array. The miniature bookcase in this example is also an array. Thus, we are storing an array inside of an array in PHP.
| |||||
Say I need to use trinket "b." To get trinket "b" from the miniature bookshelf "first_name" located on bookshelf "$_POST," I will do the following:
- I will go to "$_POST" and find a shelf labeled "first_name."
- Then, I will take "$first_name" out of "$_POST."
- Next I will look in the spot where I remember putting trinket "b."
Now, I'll write a line of PHP that will print-to-screen what I retrieved from "$first_name" -- shelf number 1.
$first_name = $_POST['first_name'];
$trinket_b = $first_name[1];
echo $trinket_b;
?>
Note that I could have just as easily written
<?php
echo $_POST['first_name'];
?>
and produced the same result. Sometimes, that is even the best way to do it
The example above, while far from complete, provides a basic way of thinking about arrays. The same idea can be applied to the other super globals -- $_GET, $_SESSION, and $_COOKIE.
Filezilla Filezilla Ftp Client, FTP SERVER vs Wsftp
By: D.Shaun Morgan
While I was writing this article, about halfway through, I realized that it would be unfair to tell my readers about
retreive images mysql php php How to get images out of mysql database with php and use them on my webpages
Author: D.Shaun Morgan
PHP Version - PHP 5x
php example post array php Visual example of how PHP handles the super-global array variable "$_POST"
Author: D.Shaun Morgan
Versions and Skill Level
how to write html form PHP php
When learning PHP to build a website, one of the very first things that any newcomer, or beginner needs to learn is how to use HTML or XHTML (both will mean the same for this tutorial.) fo
php passing variables php Pass Variables from One Page to Another -- PHP
Author: D.Shaun Morgan
Tutorial Outline :
Passing PHP variables with $_

Leave a Comment
php_example_post_array.php
How do I do the complete opposite of this tutorial?
I have a given number of values out of a select , generated by a FOR loop:
Through this I m able to generate a string with DOCUMENT.WRITELN, but I want to get this string into a TEXTBOX, without leaving the page...
After completing the form which has more values to enter I want to pass this TEXTBOX value as a single string to the database...
How can this be done?
Thanks in advance,
Bye
Ward
Re: Admin
Ok Ward, it sounds like you are talking about using javascipt to validate a form OR you are asking me how you can take the info you got out of a database or some other place and populate your textboxes with that data.
I am stabbing in the dark here but I am assuming that you somehow passed some variables to the page with your form on it or you populated some local variables that were created on the page in question with some other source of information and you want to place all those values into your form and then submit it.
When I want to pupulate my forms with variables from the script that runs on the same page , I simply echo the variable's values into the value attribute of an input or in between the opening and closing textarea tags like so:
$varTest = 'Data that you Retrieved";
<input type="text" name="var01" value="<echo varTest; ?>" />
or
<textarea name="var01" ><?php echo $varTest;</textarea>
Either of these options will place the values of your script variables into your form objects
When you submit this form those variables will go on to be processed on the page pointed to in the form action attribute.
Re: Admin
http://mrarrowhead.com/index.php?page=php_example_post_array.php