What did I get wrong in this php code?

Status
Not open for further replies.

Mike9182

In Runtime
Messages
258
Location
Altoona, PA
I'm new to php, especially databases, so this code probably contains a lot of errors. I amt trying to check the username and password from a form on the previous page. When this code runs nothing comes up, and everything that is written after the php code does not appear in the source.


PHP:
<?php
//Connect To Database
$hostname='removed for security reasons';
$username='removed for security reasons';
$password='removed for security reasons';
$dbname='Main9182';
$usertable='user';
$user = $_POST["user"] ;
$pass = $_POST["pass"] ;

mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);

//Check Username
$query = 'SELECT Username FROM $usertable';
$result = mysql_query($query);
while($result = $user) ;
	{
	$queryp = 'SELECT Password FROM $usertable' ;
	$presult = mysql_query($queryp) ;
	
	//Check Password
	while($presult = $pass) ;
		{
		setcookie("access", "Yes", time()+3600);
		echo "Login successful, click" ;
		echo "<a href='news-edit.php'>here</a>" ;
		echo "to continue" ;
		echo "<SCRIPT LANGUAGE='JavaScript'>" ;
		echo "<!--" ;
		echo "windows.location='news-edit.php ;" ;
		echo "// -->" ;
		echo "</script>" ;
		}
	
	while($presult !=  $pass) ;
		{
		echo "incorrect username or password, please" ;
		echo "<a href='login.php'>retry</a>" ;
		}
	}
while($result != $user) ;
	{
	echo "incorrect username or password, please" ;
	echo "<a href='login.php'>retry</a>" ;
	}
?>
 
Status
Not open for further replies.
Back
Top Bottom