FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
A Practical Example
Message  
Reply with quote
Post A Practical Example 
First let's set up a form for entering a username and password to add a new user into the system. Let's use an example of a form for an admin interface to administer a Company X product database for Web display.

    <html>
    <head>
    <title>Company X Products Admin Application Add New User </title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <h1>Administration Interface login: Add new User</h1>
    <form name="form1" method="post" action="admin_login_newuserbe.php">
    <p>
    <input name="uname" type="text" id="uname" size="8" maxlength="8">
       <strong>Enter User Name</strong>
    <br>
    <input name="pword" type="password" id="pword" size="8" maxlength="8">
       <strong>Enter Password</strong>
       <br><input type="submit" name="Submit" value="Add">
    </p>
    </form>
    </body>
    </html>

When the form is submitted to "admin_login_newuserbe.php" the crypt function is used to encrypt the new username. We first confirm that both fields have entries:

    if(empty($_POST[pword]) || empty($_POST[uname]))
    {
       echo "<html><head></head>
       <body><h1>You must enter both a username and password.
       <a href = \"admin_login_newuser.html\">Try Again?
       </a></h1></body></html>";
    }

Additional validation could be added to this either on the client side (using Javascript) or on the server side as needed. Next we will use crypt to encrypt our password and neatly trim leading and trailing white space from our username. They can then be stored in a database or flat file.

    else
    {
       $pwrd = crypt(trim("$_POST[pword]"));
       $user = trim("$_POST[uname]");
    //Code for accessing you database or flat file goes here.


http://www.devshed.com/c/a/PHP...unction/1/

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com