|
User Authentication - User Login |
|
|
|
|
Since we have created a database table with username and login data, you can change that particular page "insert.php" to registration.php. Or, you can make a separate page that links from your homepage next to a "User Login" form which this tutorial covers. (most websites have the login form and submit button with a hyperlink from the word "Not Registered? -Click Here" or something to that effect. Considerations: - You must have completed the tutorials for "Record Insertion."
- Created a table in your database that is called "members" with the criteria set up with PHPMyAdmin from your hosting control panel.
If you don't have DreamWeaver open already, make sure that your site is defined as in the previous tutorials and that your database connection is showing up in the database panel within the software. DreamWeaver usually defaults back to the last defined site you were working in and all you have to do is create a new php file and the Databases panel will activate showing the connection name. We will still be using the connection called "inserting." If you want to have the login on your homepage, make sure that it's a php page (index.php) and locate the area you'd like to have the login form. For this tutorial it will be a page saved as "login.php" to keep things basic. Once you have saved your php page and located the area where you would like to have the login form appear, click the "User Authentication" icon from the Application Toolbar.
Click "Log In User" - AN ERROR WILL OCCUR ASKING YOU TO CREATE A FORM IN ORDER TO USE THIS BEHAVIOR. At this point agree with the error and select the "Table" creation icon from the "Common" toolbar and create a table with the settings below, or copy and paste the code on right. | | Set it for 3 rows, 2 columns, 250pixels wide, border 1 padding and spacing set at 4. Click OK When you start to add text boxes, the program will ask you to add a form tag. Say no at this time. The best way to handle this is just to copy the code to the right and paste into the body of login.php. The code to the right should produce a table as shown to here:
| <form name="logthemin" id="logthemin"> <table width="250" border="1" cellspacing="4" cellpadding="4"> <tr> <td width="90">Username:</td> <td width="126"><label> <input type="text" name="textfield" /> </label></td> </tr> <tr> <td>Password:</td> <td><label> <input type="text" name="textfield2" /> </label></td> </tr> <tr> <td colspan="2"><label> <input type="submit" name="Submit" value="Login" /> </label></td> </tr> </table>
</form> | Notice that there is a "<form>" tag around the table, this will come in handy as soon as you click the "User Login" icon from the Application toolbar once again Click it and the following wizard applet will appear: |  | Get Input should default to "logthemin" which is the name of the form (in red above) Since we didn't name the textfields, they appear as textfield and textfield2. You'll notice that it is assumed by the wizard that these are the username and password fields. Leave them as this. Validate using connection: Select "inserting" Your table is Members Make sure that the username column is pointing to the username field from "members" The same with password. If login succeeds, go to Type in "welcome.html" - We'll create that in a few moments. If login fails: Type in "noway.html" - This page will be created and it will say something like "you are not allowed here" - This page will show up when the login and password do not match what is in the members table in your database. SELECT OK And save login.php | Create the two destination pages:- welcome.html - a simple page that says "Welcome to the site" in an H1 tag.
- noway.html - a simple page that says "You are not welcome at all!" in an H1 Tag.
Upload login.php, welcome.html, noway.html and the "Connections" folder which contains "inserting.php" - which is the MySQL connection page that permits login.php to connect and compare data entered with the data in the "members" table in your database. Point your browser to www.yourdomain.com/login.php and try it out. If you forgot the login and pass you used with www.yourdomain.com/insert.php - go back to that page and enter some other names and passwords. For the full experience, click on whoswho.php and see the names get added to your "members" table in the database. Try some bogus information in the "login.php" page and see if it takes you to that "Rude" page. | ? |
|
|
Last Updated on Monday, 04 June 2007 01:49 |