Jump to content
MakeWebGames

Recommended Posts

Posted (edited)

i keep geting this error message

Parse error: syntax error, unexpected T_LOGICAL_OR in /home/u571822004/public_html/login.php on line 11

 

this

 

<?php

session_start();

$username = $_POST['username'];
$password = $_POST['password'];

if ($username AND $password)
{

$connect = mysql_connect("xxxxxx","xxxxxxx","xxxxxxx"); or die ("Couldnt Connect To Database");
mysql_select_db("xxxxxxx") or die ("couldnt find database");

$query = mysql_query("SELECT * FROM users WHERE username='$username'"

$numrows = mysql_num_rows($query);

if($numrows !=0)

{

while ($rows = mysql_fetch_assoc($query))
{

	dbusername = $row ['username'];
	dbpassword = $row ['password'];

}
	if ($username==dbusername&&$password==$dbpassword)
	{

	ehco "Login successful.a <href='home.php'>CLick here to go home</a>";
	$_SESSION['username']=$dbusername;

	}
	else
		echo "incorrect password";
}

	else
		die ("echo "That username does not exist");

}
else
die ("Please enter a username and password
?>
Edited by illusions
Erased personal data
Posted (edited)

Just to for-warn you this script is really vunerable to hack attacks + the passwords are not secure either which you need to encrypt.

 

There was at least 10 errors i found i fixed them all:

Code:

 

<?php

session_start();

$username = $_POST['username']; // add string security
$password = $_POST['password']; //add string security

if ($username && $password)
{

$connect = mysql_connect("xxxxxx","xxxxxxx","xxxxxxx") or die ("Couldnt Connect To Database");
mysql_select_db("xxxxx") or die ("couldnt find database");

$query = mysql_query("SELECT username,password,count(username) as total  FROM users WHERE username='$username' LIMIT 1"); //add limit 1 to reduce memory useage when only searching for one result

$row = mysql_fetch_assoc($query);
if($row['total']){
$tempu = $row ['username'];
$tempp = $row ['password'];
if ($username === $tempu && $password === $tempp){ //use === not == for a more accurate checking
$_SESSION['username']=$row['username']; // add string security
echo "Login successful <href='home.php'>CLick here to go home</a>";

 }else{
 echo "incorrect login!";
}
} else {
echo "incorrect login!";
}

}else{
echo "incorrect login!";
}
?>

 

Also ADD MD5 encryption to password!

Edited by SirChick
Posted

The get to the PROBLEM.

It's a parse error, you used a semi-colon which isn't correct.

[color=#333333]$connect = mysql_connect("xxxxxx","xxxxxxx","xxxxxxx"); or die ("Couldnt Connect To Database");

Should be:

[/color][color=#333333]$connect = mysql_connect("xxxxxx","xxxxxxx","xxxxxxx") or die ("Couldnt Connect To Database");

[/color]

Posted

line 14 >>> $query = mysql_query("SELECT * FROM users WHERE username='$username'" change to

$query = mysql_query("SELECT * FROM users WHERE username='$username'");

line 45 >>> die ("Please enter a username and password change to

die ("Please enter a username and password");

Posted

thanks alot its working now. i been trying to get it to work all day.

i got another one for you.

i want a muisc to play every time some one types in my website.

but i dont want a play button or any of that stuff to show.

i just want it to auto play.

Posted
thanks alot its working now. i been trying to get it to work all day.

i got another one for you.

i want a muisc to play every time some one types in my website.

but i dont want a play button or any of that stuff to show.

i just want it to auto play.

 

VERRRRRY bad idea not everyone likes music on sites so always make sure you give your users a choice to turn off the player

But in all honest i wouldnt have one if any users are still on dial up you'll kill em..

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...