Results 1 to 5 of 5

Thread: Having issue getting id in url and login

  1. #1
    Join Date
    May 2012
    Posts
    210
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Having issue getting id in url and login

    Hi

    I have built a sign up form which works perfect and a login form that works perfect but if I try to add the id number into the url using php, it makes the login form load the same page and not redirect to the profile page, below is the code I have on the login form processing page

    PHP Code:
    <?php

    ob_start
    ();
    session_start();

    $username $_POST['username'];
    $password $_POST['password'];
     
    $_SESSION['username'] = $username;
     
    $conn mysqli_connect('localhost''xxxx''xxxx''xxxx');
     
    $id=$_GET['id'];
     
    $username mysqli_real_escape_string($conn$username);
    $query "SELECT password, salt
            FROM recruiters
            WHERE username = '
    $username' AND id=$id;";
     
    $result mysqli_query($conn$query);
     
    if(
    mysqli_num_rows($result) == 0// User not found. So, redirect to login_form again.
    {
        
    header('Location: recruiter-login.php');
    }
     
    $userData mysqli_fetch_array($resultMYSQL_ASSOC);
    $hash hash('sha256'$userData['salt'] . hash('sha256'$password) );
     
    if(
    $hash != $userData['password']) // Incorrect password. So, redirect to login_form again.
    {
        
    header('Location: recruiter-login.php');
    }else{ 
    // Redirect to home page after successful login.
        
    header('Location: recruiter-profile.php?id=$id');
        
    }
    ?>
    I put error reporting in and is not displaying any errors so is one good thing

    If I take out AND id=$id from the sql query, the login works and logs me in

    Hope someone can help

    Thank you in advance

    Ian
    Last edited by Beverleyh; 12-30-2015 at 12:04 PM. Reason: Details removed

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,035
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Have you tried it with apostrophes around the $id variable (so it looks like the username pairing)?
    Code:
    AND id = '$id'
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    May 2012
    Posts
    210
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by Beverleyh View Post
    Have you tried it with apostrophes around the $id variable (so it looks like the username pairing)?
    Code:
    AND id = '$id'
    Hi Beverley, thank you for the reply, appreciate it

    I have got it sussed now, sorry

    Also is it possible to edit or delete this thread or my original post as realised it has my db info in

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,035
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    OK - sorted
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #5
    Join Date
    May 2012
    Posts
    210
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by Beverleyh View Post
    OK - sorted
    Thank you so much, really appreciate it

Similar Threads

  1. Replies: 3
    Last Post: 02-15-2011, 02:37 AM
  2. AnyLink Drop Down Menu - border issue *and* FF alignment issue
    By trjonas in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 12-18-2007, 05:58 AM
  3. Email issue -- Carbon Copy Issue
    By Humper in forum HTML
    Replies: 0
    Last Post: 09-01-2006, 09:01 PM
  4. Email issue -- Carbon Copy Issue
    By Humper in forum JavaScript
    Replies: 0
    Last Post: 09-01-2006, 07:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •