Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

know how to connect, now what?

Status
Not open for further replies.

rmccoy

MIS
Mar 22, 2001
4
0
0
US
I have learned how to connect, now I would like the user to be able to login to a certain webpage. Say coming from a page called login.htm, the form submits to a login.php page which checks the MySQL database, checks to see if the username and password are valid, then redirects to the appropriate page. anybody know where there is some code on this or have any suggestions? Thanks
 
This is how I would do it in PHP:
Connect to the dbase
Check the username and password
If all correct, print the html refresh tag that redirects the user to a page within 0 seconds.

<?
mysql_connect(&quot;host&quot;,&quot;username&quot;,&quot;password&quot;);
//connecting to the database host

$result = mysql_query(&quot;dbase&quot;,&quot;SELECT * FROM table WHERE
username='$username' AND password='$password'&quot;);
//immediately checks the username & password

if($login = mysql_fetch_array($result))
//if any resultset was returned, meaning username & password were correct

print(&quot;<meta http-equiv='refresh' content='0;URL=newPage.htm'>&quot;);
//This redirects the user to the newPage.htm
else
print(&quot;wrong login&quot;);
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top