• Home

Logo

Navigation
  • Home
  • Articles
    • Content Writing
    • Design
    • General
    • Internet Marketing
    • Social Media
    • Tools and Tips
    • Usability
    • Web Hosting Articles
  • Tutorials
    • AJAX Tutorials
    • ASP Tutorials
    • C# Tutorials
    • CGI and Perl Tutorials
    • CSS Tutorials
    • Flash Tutorials
    • HTML Tutorials
    • Illustrator Tutorials
    • Java Tutorials
    • JavaScript Tutorials
    • Linux Tutorials
    • Miscellaneous Tutorials
    • MySQL Tutorials
    • Photoshop Tutorials
    • PHP Tutorials
    • Python Tutorials
    • Wireless Tutorials
    • WordPress Tutorials
    • XML Tutorials
  • Scripts
    • AJAX Scripts
    • ASP Scripts
    • ASP.NET Scripts
    • CGI & Perl Scripts
    • Flash Scripts
    • Java Scripts
    • JavaScript Scripts
    • PHP Scripts
    • Python Scripts
    • Remotely Hosted
    • Tools and Utilities
    • XML Scripts
  • Answers
  • Online Services
  • Tools

Create and Use a User Input Form

By Darren W. Hedlund | on Jun 20, 2005 | 0 Comment
HTML Tutorials PHP Tutorials
  • Tweet
  • Share
  • Tweet
  • Share

Create and Use a User Input Form

So how do you access the information you submitted via HTML in the script (script.php)?  Well amazingly, there are several ways to get the information.  It’s up to you to decide which method best suites you, and then go with that.  When you submit a form to a script, a certain set of variables are automatically created for you.

http://www.website.com/script.php" method="post">
Form 1: <input type="text" name="form1"><BR>
Form 2: <input type="text" name="form2"><BR>

<input type="submit" value="submit">
</form>

</body>
</html>

Let’s now pretend I submitted that form with information via the "post" method filling in "form1" with "hi" and "form2" with "bye".  To see this visually, I’ll show you how it would look via the "get" method:

http://www.website.com/script.php?forms1=hi&forms2=bye

Remember that the only differences between the "post" and "get" methods are:
-"post" doesn’t cache information, while "get" does
-the "get" method is limited in the amount of information you can send while the "post" method is not

The first way to access the information is via the "superglobals" PHP provides.  "Superglobals" are variables that can be accessed anywhere in the script regardless of scope (we’ll learn about this later when we get to functions).  The "superglobals" are 9 special associated arrays which hold ALL the information you input into a script.  Here they are:

$_SERVER – these are variables set by the server

$_GET – this is information you send via the "get" method into your script

$_POST – this is information you send via the "post" method into your script

$_COOKIE – this arrays holds all cookie information your computer sends to the script

$_FILES – when you upload files in PHP, they are held inside this array

$_ENV – the environmental variables

$_REQUEST – a combination of all user-input to your script

$_SESSION – much like cookies, these are session variables which hold information for you

I will be concentrating almost all the examples on the "post" and "get" methods because they are the easiest to follow.  There are equivalent older versions of the above which are not "superglobals" and only exist in the global scope (again we’ll get into this when we discuss functions).  Here are the "superglobals" and their old deprecated counterparts (remember again that these are associated arrays):

$_SERVER – $HTTP_SERVER_VARS
$_GET – $HTTP_GET_VARS
$_POST – $HTTP_POST_VARS
$_COOKIE – $HTTP_COOKIE_VARS
$_FILES – $HTTP_POST_FILES
$_ENV – $HTTP_ENV_VARS
$_REQUEST – new, didn’t exist before
$_SESSION – $HTTP_SESSION_VARS

By now you should be totally confused, and I completely understand if you are, because I haven’t explained a thing about how to use these arrays.  Let’s take out "get" method example:

http://www.website.com/script.php?forms1=hi&forms2=bye

Here is how I would access the "form1" and "form2" information is submitted inside the script:

http://www.website.com/script.php?name1=Jeff&name2=Joseph (remember, this means you either typed this directly inside your address bar in your browser, or that you submitted forms with names "name1" and "name2" via HTML with the "get" method).

Share this story:
  • tweet

Author Description

Darren Hedlund is a freelance Web developer, writer, and data analyst. Darren has a degree in Computer Information Science and has spent the last 15 years developing application and environments from hand held, windows, web, virtual science, gaming, artificial intelligence and graphics design.

Darren's coding knowledge ranges from C+, Visual Basic, .NET, PHP, JSP, REXX, KIXX, and many others. His graphical and environmental knowledge stems in Macromedia Flash, 3D studio Max, Curious Labs Poser, Adobe Photoshop, and many others. Darren works in many platforms ranging from database, visual design, and, system development.

No Responses to “Create and Use a User Input Form”

You must be logged in to post a comment.

Connect With Us

RSSSubscribe 1,240Followers 494Likes
  • Popular
  • Recent
  • Comments
  • Creating Energy Spheres in Photoshop

    Apr 15, 2008 - 96 Comments
  • Easy Screen Scraping in PHP with the Simple HTML DOM Library

    Aug 6, 2008 - 20 Comments
  • Calculating date difference more precisely in PHP

    Mar 7, 2008 - 13 Comments
  • When Does Hosting Your Website in the Cloud Make Sense?

    Oct 8, 2010 - 2 Comments
  • Fun with the Microsoft Managed Extensibility Framework Part 2

    Oct 6, 2010 - 0 Comment
  • Fun with the Microsoft Managed Extensibility Framework Part 1

    Sep 22, 2010 - 0 Comment
  • Website Management on the go with the iPad

    I appreciated your post, but I was looking for something I didn't...
    November 24, 2012 - drmoderator
  • Creating Energy Spheres in Photoshop

    I'm a little stuck down here especially at the step of creating the...
    November 23, 2012 - sarah
  • Running background processes in PHP

    Can you give an example? As see it, you can use this only when you...
    November 16, 2012 - Shaked Klein Orbach
Developer Resources
  • Tutorial Directory
  • Learn HTML
  • Learn PHP
  • Learn CSS
  • Learn AJAX
  • Learn JavaScript
  • Learn Pear
  • White Papers
  • Resources
    • NetVisits Web Directory
    • Realtor Pixels
    • Answers On The Run
    • Ask A Geek
  • Recent Posts

    • When Does Hosting Your Website in the Cloud Make Sense?
    • Fun with the Microsoft Managed Extensibility Framework Part 2
    • Fun with the Microsoft Managed Extensibility Framework Part 1
    • Website Management on the go with the iPad
    • Code Contracts in C# 4.0 – Part 1

    Calendar

    May 2013
    M T W T F S S
    « Oct    
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  

    Recent Comments

    • drmoderator on Website Management on the go with the iPad
    • sarah on Creating Energy Spheres in Photoshop
    • Shaked Klein Orbach on Running background processes in PHP
    • Thomas Cuvillier on How To Upload Files Using PHP
    • rizal aditya on Extracting text from Word Documents via PHP and COM
    • Home
    © 2003 - 2013 DeveloperTutorials.com. All Rights Reserved. Privacy Policy.