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  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT