Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    141
    Thanks
    8
    Thanked 0 Times in 0 Posts

    issues while coding a login

    Code isnt redirecting to welcome.php, any ideas on why my code isnt working the way I hoped? Thanks in advance for help.


    Code:
    <?php
    
    include('config.php');
     @ob_start();
    if (isset($_POST['submit']))
    
    {
    $username= $_POST['username'];
    $password= $_POST['password'];
    $myusername = mysql_real_escape_string($username);
    $mypassword = mysql_real_escape_string($password);  
    
    
    	
    $sql="SELECT id FROM users WHERE username='$myusername' and password='$mypassword'";
    $result= mysql_query($sql) or die(mysql_error());
    $row= mysql_fetch_array($result);
    
    
    $count=mysql_num_rows($result);
    
    
    // If result matched $myusername and $mypassword, table row must be 1 row
    if($count==1)
    {
    header('Location: welcome.php');
    
    
    
    
    }
    }
    else {
    ?>
    
    <!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 Page</title>
    
    <style type="text/css">
    body
    {
    font-family:Arial, Helvetica, sans-serif;
    font-size:14px;
    
    }
    label
    {
    font-weight:bold;
    
    width:100px;
    font-size:14px;
    
    }
    .box
    {
    border:#666666 solid 1px;
    
    }
    </style>
    </head>
    <body bgcolor="#FFFFFF">
    
    
    <div align="center">
    <div style="width:300px; border: solid 1px #333333; " align="left">
    <div style="background-color:#333333; color:#FFFFFF; padding:3px;"><b>Login</b></div>
    
    
    <div style="margin:30px">
    
    <form action="" method="post">
    <label>UserName  :</label><input type="text" name="username" class="box"/><br /><br />
    <label>Password  :</label><input type="password" name="password" class="box" /><br/><br />
    <input type="submit" value=" Submit " name="submit"/><br />
    
    </form>
    <div style="font-size:11px; color:#cc0000; margin-top:10px"></div>
    </div>
    </div>
    </div>
    </body>
    <?php } ?>
    </html>
    Last edited by amcf1992; 01-21-2014 at 12:49 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Tags for this Thread

    Posting Permissions

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