Jump to content

Login System stopped working!


adam87

Recommended Posts

Hey I recently built a login system for a project of mine, it was working fine until I came to check it today, it is connecting to the database(getting other data for a different section of the website) but everytime I enter the login details it doesnt login.

 

I was wondering if someone could quickly scan over my code just to see why this could be.

 

<?php 
session_start();

include 'dbc.php';
include 'browser_gather.php';



$user_name = mysql_real_escape_string($_POST['uname']);

if ($_POST['Submit']=='Login')
{
$md5pass = md5($_POST['pwd']);
$sql = "SELECT id,user_name FROM users WHERE 
            user_name = '$user_name' AND 
            user_pwd = '$pwd' AND user_activated='1'"; 
         
$result = mysql_query($sql) or die (mysql_error()); 
$num = mysql_num_rows($result);
$assoc = mysql_fetch_assoc($result);

    if ( $num != 0 ) { 

   $_SESSION['user']= $user_name;
   $_SESSION['uid'] = $assoc['id'];
      
      list($user_id,$user_name) = mysql_fetch_row($result);

      
         
      if (isset($_GET['ret']) && !empty($_GET['ret']))
      {
      header("Location: $_GET[ret]");
      } else
      {
      header("Location: index.php");
      }
      //echo "Logged in...";
      exit();
    } 

header("Location: index.php?msg=Password and/or Username dont match");


//echo "Error:";
exit();      
}

?>



<!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=utf-8" />
<title>Gigbookers: Home</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />


</head>

<body class="oneColLiqCtrHdr">

<div id="container">
  <div id="header">
  <div class="nav">
  <ul id="MenuBar1" class="MenuBarHorizontal">
    <li><a href="index.php">Home</a>          </li>
    <li><a href="tickets.php">Tickets</a></li>
    <li><a href="news.html">News</a>          </li>
    <li><a href="contact.php">Contact Us</a></li>
      </ul>
  
  </div> 
</div>
  <div id="home">
    <div id="leftcontent">
    <?php if ($_SESSION['user'] == true)
{ ?>
      <p>Welcome Back <br /><? echo $_SESSION['user'] ;?>  </p>
      <a href="changepwd.php">Settings</a> | <a href="logout.php">Logout</a>
      <? }
       else{ ?>
      <form name="form1" method="post" action="">
        <label>Username <br />
        <input name="uname" type="text" id="uname" />
        </label>
        <p>
          <label>Password<br />
          <input name="pwd" type="password" id="pwd" />
          </label>
        </p>
        <p>
        <?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>
        </p><p>
          <label>
          <input type="submit" name="Submit" value="Login" />
          </label>
        </p>
        <p>
        <input type="button"  onclick="document.location = 'register.php'" value="Register"/>        
        <p>
        
        <p><a href="forgot.php">Forgot Password </a>
      </form><? } ?>

    </div>
<p class="style2">

  <br />  Welcome to Gigbookers new improved website, would like to apologize for any inconvenience the maintenance has caused to you all. But you should now hopefully enjoy a nicer and faster service for purchasing the latest tickets for the hottest bands around.<br />
   <br />
  
You will notice some major cosmetic changes to the site and all the way the functionality of the site works, if any errors occur whilst using the site feel free to post a comment on the contact form and we will look in to it as soon as we can.</p>
<p><a href="msg_board.php">Messsage Board</a></p>
<p> </p>
<p> </p>
  </div>
  <div id="footer">
    <div class="admin"><a href="terms.html" class="style1">T & C</a>    <a href="admin_login.php" class="style1">Admin</a></div>
  <!-- end #footer --></div>
<!-- end #container --></div>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>

 

It was working roughly around 3-4weeks ago has i had to demonstrate it, just finiding it really frustrating and hoping there is a quick fix.

 

Thanking you

Adam

Link to comment
https://forums.phpfreaks.com/topic/194339-login-system-stopped-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.