Jump to content

Login in Problems


jukie

Recommended Posts

Hi I have developed a register form and a login form, register form is working but the login form is not working.

login form. The login check just takes me back to the index page instead of mybookmarks.php. Can anyone see the issue in these codes?

<form id="form1" action="logincheck.php" id="op"  method="post">
            <fieldset> <legend>Get On This Login</legend>
                <input type ="hidden" name="submitted" id="submitted" value="1"/>
  <label for='Username' >UserName</label>
<input type='text' name='Username' id='Username'  maxlength="50" />
 
<label for='Password' >Password</label>
<input type='password' name='Password' id='Password' maxlength="50" /><br>
 
<input type='submit' name='Submit' value='Login' />
 
</fieldset>
              
        </form>

logincheck.php

<?php

 
 



        
 session_start();
 // dBase file
 include "connection.php";

 
// Inialize session
 session_start();

// Include database connection settings


// Retrieve username and password from database according to user's input
 $login = mysql_query("SELECT * FROM members WHERE (Username = '" . mysql_real_escape_string($_POST['Username']) . "') and (Password = '" . mysql_real_escape_string(md5($_POST['Password'])) . "')");

// Check username and password match
 if (mysql_num_rows($login) == 1) {
 // Set username session variable
 $_SESSION['Username'] = $_POST['Username'];
 // Jump to secured page
 header('Location: mybookmarks.php');
 }
 else {
 // Jump to login page
 header('Location: index.php');
 }

  
 
  


?>

I have added the register connection incase this can help solve the issue

 // dBase file
 include "connection.php";

//retrieving data from form

$Username  =$_POST ['Username'];
$emailaddress =$_POST ['emailaddress'];
$FirstName = $_POST ['FirstName'];
$Password =$_POST ['Password'];


//Protect from SQL Injection

$Username = mysql_real_escape_string($Username);
$emailaddress = mysql_real_escape_string($emailaddress);
$FirstName= mysql_real_escape_string($FirstName);
$Password = mysql_real_escape_string($Password);

//hash the password

$Password = md5($pword);


    

$query = "INSERT INTO members( Username, Password, emailaddress, FirstName)
       VALUES ('$Username', '$Password','$emailaddress', '$FirstName')";
       $sucess = mysql_query($query);
       
       if ($sucess) header("Location: index.php");
  

mysql_close($conn);

Thank you for reading.

Edited by jukie
Link to comment
Share on other sites

Sorry, I have sorted it out, I seen the error right away after reading the post, it was the hash part

$Password = md5($pword);

its should have been password not pword, don't know why I couldn't see this in the editor tho. sorry

Link to comment
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.