Jump to content

Recommended Posts

I need a login script, I finally got my registration working..it uses md5 encryption. So I'll need a user and pass field and it has to change to md5 before it goes through to the database. I need it to use cookies and I would prefer only 1 cookie be set upon login. I have absolutely no idea how to go upon this...

table name - users
connect - inc/connect.php
row - username
row - pass

If someone could just give me the basic maybe I could try and get it working and post back for help.

Thanks!
Link to comment
https://forums.phpfreaks.com/topic/10670-login-script/
Share on other sites

[!--quoteo(post=377936:date=May 28 2006, 07:18 PM:name=localhost)--][div class=\'quotetop\']QUOTE(localhost @ May 28 2006, 07:18 PM) [snapback]377936[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I need a login script, I finally got my registration working..it uses md5 encryption. So I'll need a user and pass field and it has to change to md5 before it goes through to the database. I need it to use cookies and I would prefer only 1 cookie be set upon login. I have absolutely no idea how to go upon this...

table name - users
connect - inc/connect.php
row - username
row - pass

If someone could just give me the basic maybe I could try and get it working and post back for help.

Thanks!
[/quote]

Id recommend sessions! there easier!...lol....
Link to comment
https://forums.phpfreaks.com/topic/10670-login-script/#findComment-39822
Share on other sites

What are the advantages and disadvantages between sessions and cookies?

I'm still new to PHP...so by looking up some cookie stuff I was able to code this...but I know it won't work I just need to know what I have to do to make it work...

[code]

<?php

include('inc/connect.php');

$uname = $_POST['uname'];
$pass = $_POST['pass'];

$chkpass = md5($pass);

$query = "SELECT * FROM users WHERE username==$uname"
$result = mysql_query($query) or die('Failed to connect to user database');

$value = '$_COOKIE["Pranksters"]';

setcookie("Pranksters", $value);


?>

[/code]
Link to comment
https://forums.phpfreaks.com/topic/10670-login-script/#findComment-39824
Share on other sites

Anybody?

EDIT - I've added the form on the bottom, code here:

[code]
<style type="text/css">
<!--
.style3 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: x-small;
}
-->
</style>

<span class="style3">Username:
<input type="text" name="uname">
<br>
Password:
<input type="password" name="pass">
<br>
<input type="submit" name="submit" value="Login">
</span>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/10670-login-script/#findComment-39842
Share on other sites

Here's my current code:

[code]
<?php
session_start();
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login - Pranksters</title>
<style type="text/css">
<!--
.text {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: x-small;
    color: #666666;
}
#form1 #username {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #666666;
}
body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
}
-->
</style>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="59%" border="0" cellspacing="3">
    <tr>
      <td>Username:
        <br />
        <input name="username" type="text" id="username" /></td>
    </tr>

    <tr>
      <td>Password:      
        <br />
        <input name="password" type="password" id="username" />
      <br />
      <span class="text">
      <input name="remember" type="checkbox" id="remember" value="yes" />
Keep me logged in on this computer </span>      <br /></td>
    </tr>
    <tr>
      <td><input name="Login" type="submit" id="username" value="Submit" /></td>
    </tr>
    <tr>
      <td><?php
    
    //Include Connection File
    include('inc/connect.php');
    
    //If login is pressed
    if(isset($_POST['Login']))
    {
        // Get the user info
        $username = strip_tags($_POST['username']);
        $password = strip_tags($_POST['pass']);
        $user = addslashes($username);
        $pass = addslashes($password);
        $md5pass = md5($pass);
        
        // Get the date
        $date = date("d/m/y");
        
        // See if they are in the databse
        $query = mysql_query("SELECT * FROM `users` WHERE `username` = '$username' AND `pass` = '$md5pass' LIMIT 1") or die(mysql_error());
        
        if(mysql_num_rows($query) >= "1")
        {
            
                    // Cookie is equal to 10 years
                    setcookie("loggedin", "$username", time()+60*60*24*365*10, "/", "thecodingplace.com", 0);
            
            header("Location: index.php");
        }
        else
        {
            echo 'Not logged in';
        }
    }  
?></td>
    </tr>
  </table>
</form>
</body>
</html>


[/code]

problem is, it sets the cookie but says not logged in, and it doesnt redirect...help?
Link to comment
https://forums.phpfreaks.com/topic/10670-login-script/#findComment-39923
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.