Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with Login Page

Posted on 2006-11-11
5
Medium Priority
?
207 Views
Last Modified: 2006-11-18
I found this login code at php noise and wanted to use it but I do not understand where it gets any info from mysql to verify login at......

Need help understanding it.  I found this at http://www.phpnoise.com/tutorials/26/1

here is the code--->

<?php
// valid login credentials
$username = 'admin';  
$password = 'admin_pass';
// grab current time
$time=time();  

// handle the logout event
if ($logout == true) {    
 setcookie ("user", md5($_POST[user]), $time-3200);  
 setcookie ("pass", md5($_POST[pass]), $time-3200);  
 header("Location: logintest.php");
}

// handle validation event
if ($_POST[user] && $_POST[pass]) {    
 if ($_POST[user]==$username && $_POST[pass]==$password)
 {
  setcookie ("user", md5($_POST[user]), $time+3200);  
  setcookie ("pass", md5($_POST[pass]), $time+3200);  
  header("Location: logintest.php");
 } else { $login_error= true; }
}
 
// handle login event, both successful and erroneous, or show login screen  
if ($login_error == true) { ?>
 <table align=center style="font-family:arial; font-size:12; border:1 solid #000000;">
  <tr><td align=center bgcolor=#BAC7D8>LOGIN ERROR</td></tr>
  <tr><td align=center><b>Invalid Username and/or Password</b><br><br>
      <a href=logintest.php>Back</a></td></tr>
 </table>
<?
} elseif ($_COOKIE[user] == md5($username) && $_COOKIE[pass] == md5($password)) { ?>
 <table align=center style="font-family:arial; font-size:12; border:1 solid #000000;">
  <tr><td align=center bgcolor=#BAC7D8>SECURE AREA</td></tr>
  <tr><td align=right><a href=logintest.php?logout=true>Logout</a></td></tr>
  <tr><td>You have successfully logged in.<br><br>
   Encrypted Username: <b><?=  $_COOKIE[user] ?></b><br>
   Encrypted Password: <b><?= $_COOKIE[pass] ?></b><br>
  </td></tr>
 </table>
<?
} else {  
?>
<form action=logintest.php method=post>
 <table align=center style="font-family:arial; font-size:12; border:1 solid #000000;">
  <tr><td colspan=2 align=center bgcolor=#BAC7D8>LOGIN</td></tr>
  <tr><td align=right>Username: </td><td><input type=text name=user size=15></td></tr>
  <tr><td align=right>Password: </td><td><input type=password name=pass size=15></td></tr>
  <tr><td align=center colspan=2><input type=submit value=Login></td></tr>
 </table>
</form>
<?
}
?>
0
Comment
Question by:aumandg
  • 3
  • 2
5 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 17921676
aumandg,

This code doesn't check the user name and password against a database.  It only supports one user name and password and they are written write in the code.  The lines below set the user name as admin and the password as admin_pass.  You can change each variables value to the one you want.

$username = 'admin';  
$password = 'admin_pass';

It will take some relatively major changes to this code to have it work with a database and support individualized logins.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 

Author Comment

by:aumandg
ID: 17923606
Ah, ok....

I am looking for a login that will check the data base for usser and password with a time out and log out.  Do you know of any code on line.  I have done a search here but have not found anything that I understand, that is simple.
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 2000 total points
ID: 17926299
I don't have a specific script to recommend to you for that.  Another expert may have one though.  I have found one PHP question that does have a script and some good information at http:Q_21182871.html.  There are a number of pre-made scripts at http://www.hotscripts.com/PHP/Scripts_and_Programs/User_Authentication/.  I hope that one of these helps otherwise let us know here and we may be able to find or come up with something else.

bol
0
 

Author Comment

by:aumandg
ID: 17929883
bol,

I found a great login script at hotscripts.com!  Super easy and a no brainer for anyone.....

Thank you for the hotscripts website forgot all about that place!

The script that I am using is here

http://www.mpdolan.com/login_redirect.htm

I RECOMMEND THIS TO ALL!  CAN NOT SAY HOW MUCH TIME THIS WILL SAVE YOU!
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 17931138
Great!  Good choice to go for a pre-made script.  I'm glad I could help.  Thank you for the grade, the points and the fun question.

bol
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question