PHP
  Home arrow PHP arrow Page 3 - PHP 101 (Part 2) - Shakespeare's Rose
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

PHP 101 (Part 2) - Shakespeare's Rose
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2000-08-08

    Table of Contents:
  • PHP 101 (Part 2) - Shakespeare's Rose
  • Form...
  • ...And Function
  • Operating With Extreme Caution
  • Shakespeare In The Matrix
  • If Not This, Then What?
  • Fortune Smiles
  • Submitting To The King
  • Miscellaneous Notes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    PHP 101 (Part 2) - Shakespeare's Rose - ...And Function


    (Page 3 of 9 )

    Now for the other half of the puzzle - the "login.php4" script. Normally, this script would accept the name entered, check whether the user existed, and either grant or deny access to the site. Since we have yet to cover PHP's conditional statements and logical operators, we're not going to demonstrate that just yet - instead, we're simply going to show you how the data submitted in the first form is injected into "login.php4" and can be used in that file.

    Here's "login.php4"

    <html> <head> <basefont face="Arial"> </head> <body> <center> <font face="Arial" size="-1"> I wonder if you've heard of Shakespeare, <? echo $name; ?>. <p> He postulated that a rose by any other name would smell just as sweet. <p> What do you think? </font> </center> </body> </html>
    And when you enter some data into the form [say "bill"] and submit it, here's what you should see:

    I wonder if you've heard of Shakespeare, bill.

    He postulated that a rose by any other name would smell just as sweet.

    What do you think?


    As you can see, whenever a form is submitted to a PHP script, all variable-value pairs within that form automatically become available for use within the script. In the example above, once the form is submitted, the variable $name is automatically created in the PHP script "login.php4", and is populated with the value entered into the form by the user.

    If you were to try doing the same thing in Perl, you'd need to explicitly write code to extract and obtain the values of the variables in the form. By automatically creating and populating the variables for you, PHP simplifies your code and speeds up development time - two reasons why PHP is preferred to Perl when it comes to form processing.

    Obviously, PHP also supports the POST method of form submission. All you need to change the METHOD attribute to "POST".

    More PHP Articles
    More By Vikram Vaswani and Harish Kamath, (c) Melonfire


     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway