6 Replies - 811 Views - Last Post: 07 October 2012 - 10:21 AM Rate Topic: -----

#1 c9-adams  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 98
  • Joined: 12-December 11

Login Fault

Posted 07 October 2012 - 07:25 AM

Hi guys,

I am currently making a registration and login form for my website. It works completely fine on my home pc however when I test it on a university computer there are problems. I can successfully register a user and their details are added to the database. When the user logs in they are navigated to their own unique account page. This is where I am having difficulties as when they login their details are not echoed. I am pretty sure its something to do with my sql but just wanted to get some feedback. I have attached the required files.

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Login Fault

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3101
  • View blog
  • Posts: 19,141
  • Joined: 14-September 07

Re: Login Fault

Posted 07 October 2012 - 07:57 AM

Moved to PHP. Putting code in the body of the post will usually generate more help than naught.
Was This Post Helpful? 0
  • +
  • -

#3 c9-adams  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 98
  • Joined: 12-December 11

Re: Login Fault

Posted 07 October 2012 - 08:00 AM

Members.php -
<?php
require"config2.php";
session_start();
$username = $_REQUEST['username'];
$gtuserinfo = mysql_query("SELECT * FROM users WHERE username = '$username'");
$userinfo = mysql_fetch_assoc($gtuserinfo);
$fname = $userinfo['fname'];
$lname = $userinfo['lname'];
$email = $userinfo['email'];
$default="";
?>
<!Doctype html>
<html>
<head>
<title>
Welcome <?php echo $fname;?> <?php echo $lname;?>
</title>
<style TYPE="text/css">
html {
	background: url(sunflowers.jpg) no-repeat center center fixed; 
	-webkit-background-size: cover;
	-moz-background-size: cover;
	-o-background-size: cover;
	background-size: cover;
}
#register{
position: relative;
right: -11.4em;
top: 0.9em;
width: 599px;
height: 488px;
text-align: left;
font-family: calibri;
font-size: 16px;
padding-top: -26px;
padding: 5px;
color: white;
background-color: green;
-moz-border-radius: 15px;
border-radius: 15px;
}
input:focus {
background-color: yellow;
}
		h6 {
		height: 10px;
		position: relative;
		top: -9.6em;
			color: white;
			font-size: 16px;
			font-family: Arial, Helvetica, sans-serif;
			background-color: brown;
			float: center; 
			padding: 10px;
			-moz-border-radius: 15px;
            border-radius: 15px;
		}
		#registration{
		position: relative;
		top: -7em;
		}
		p{
		border-bottom: 2px dotted orange;
		}
		#link{
		position: relative;
		right: -6em;
		}
</style>
</head>
<body>
<div id="register">Welcome to your member area <font color="yellow"><?php echo $fname;?> <?php echo $lname;?></font>.<a href="index2.php" id="link"><font color="pink"><b>Want to logout <?php echo $fname ?>?</b></font></a>
<br>
<br>
Username: <font color="yellow"><?php echo $username;?></font>
<br>
<br>
First Name: <font color="yellow"><?php echo $fname;?></font>
<br>
<br>
Last Name: <font color="yellow"><?php echo $lname;?></font>
<br>
<br>
Email <font color="yellow"><?php echo $email;?></font>
</p>
Thankyou <?php echo $fname ?> for logging into this website. Now that you are logged in, you will have the oppurtunity to add products to your shopping cart and buy our products.<br><br><font color="orange">*Updates*</font>Do you like Waterfalls <?php echo $fname ?>?<br><br>Well we have a new waterfall fountain in stock for just 80.<br><br></p>
Are you ready <?php echo $fname ?> to begin shopping? If so, then please click on the link below to enter the world of online shopping.
</p>
<center><a href="shopping-home.php"><font color="pink"><b>Begin shopping>>></b></font></a></center>
</body>
</html>


login process.php -
<?php
include"config2.php";
$username = $_POST['username'];
$password = md5($_POST['password']);

$query = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
$data = mysql_fetch_assoc($query);

if(mysql_num_rows($query)){
session_start();
$_SESSION['username'] = $data['username'];
header("Location: members.php?username=$username");
if (empty($username)) {
    header("Location: exists.php");
}
elseif (empty($password)) {
    header("Location: exists.php");
}
exit;
}
header("Location: login.php");
?>

Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2984
  • Posts: 10,319
  • Joined: 08-August 08

Re: Login Fault

Posted 07 October 2012 - 08:22 AM

  • Does any information show?
  • When you registered them, did you hash (as you should) the password?
  • Why are you using deprecated and insecure mysql functions?

Was This Post Helpful? 0
  • +
  • -

#5 c9-adams  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 98
  • Joined: 12-December 11

Re: Login Fault

Posted 07 October 2012 - 08:55 AM

I just tried it on my home computer using the same code and information is showing however in university they use a different version of mysql so would that affect it?
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2984
  • Posts: 10,319
  • Joined: 08-August 08

Re: Login Fault

Posted 07 October 2012 - 09:01 AM

Not likely.
Was This Post Helpful? 0
  • +
  • -

#7 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 440
  • View blog
  • Posts: 1,867
  • Joined: 30-April 10

Re: Login Fault

Posted 07 October 2012 - 10:21 AM

View Postc9-adams, on 07 October 2012 - 08:55 AM, said:

I just tried it on my home computer using the same code and information is showing however in university they use a different version of mysql so would that affect it?

This is unlikely but if this were the issue it would give you a mysql syntax error you could print. Look into MySQLi and PDO for better security.

If you get an error post it to get more help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1