can you please help me with this code of mine?

Discussion in 'HTML & Website Design' started by nhet.nidua, Oct 9, 2012.

  1. #1
    when i login my acct,nothing is being posted.it does not redirect with any of the pages its supposed to be in..
    these is the codes..please help..thank you!

    <?php


    session_start();
    $username = $_POST['username'];
    $password = $_POST['password'];


    if ( isset ($_POST['username']) )
    {
    $connect = mysql_connect("localhost","root","") or die ("could'nt connect to db");
    mysql_select_db("tesda") or die ("cant connect");
    $sql=("SELECT * FROM login WHERE username='$username'");
    $result=mysql_query($sql);
    $row=mysql_fetch_array($result);

    if($result !=0 )
    {
    while($row=mysql_fetch_assoc($result))
    {
    $dbusername = $row['username'];
    $dbpassword = $row['password'];
    }
    if ($username==$dbusername&&$password==$dbpassword){

    if($row['name'] == $_POST['name'])
    {

    if($_POST['username']=='tesda1'){
    header('Location: expi1.php');
    }
    else if($_POST['username']=='tesda2'){
    header('Location: expi2.php');
    }
    else if($_POST['username']=='tesda3'){
    header('Location: expi3.php');
    }
    else if($_POST['username']=='tesda4'){
    header('Location: expi4.php');
    }
    else if($_POST['username']=='tesda5'){
    header('Location: expi5.php');
    }
    else if($_POST['username']=='tesda6'){
    header('Location: expi6.php');
    }
    else if($_POST['username']=='tesda7'){
    header('Location: expi7.php');
    }
    else if($_SESSION['username']="$dbusername"){
    header('Location: attempt1.php');
    }
    else if($_SESSION['username']="$dbusername"){
    header('Location: attempt2.php');
    }
    else if($_SESSION['username']="$dbusername"){
    header('Location: attempt3.php');
    }
    }
    }
    }
    }
    ?>
     
    nhet.nidua, Oct 9, 2012 IP
  2. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,708
    Likes Received:
    49
    Best Answers:
    9
    Trophy Points:
    150
    #2
    Try and echo out the username/password variables to make sure they are posting.

    I also think this bit is wrong:

    You've set the variable to $username,$password not $dbusername,$dbpassword
     
    scottlpool2003, Oct 9, 2012 IP
  3. nhet.nidua

    nhet.nidua Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    when I tried and echo out the username and password, an error came out.. this is what it says
    Warning
    : Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\expie\logging.php:6) in C:\xampp\htdocs\expie\logging.php on line 28

    what should I do with this?
    Sorry,I'm not that good in programming but I have to that's why I posted this problem here..please,please I really need help..anyway,thanks for the earlier reply.hope you'll reply again..thanks!
    :)
     
    nhet.nidua, Oct 10, 2012 IP