Jump to content

Login Form - Help


jaybeeb

Recommended Posts

Trying to make a simple login form. I know what I have is not very secure, but I do not need it to be secure.

 

I just keep getting an "unexpected end" error. Any ideas?

Thanks

 

<BODY>
<HTML>
<?php

mysql_connect("localhost","root", "") or die (mysql_error());
mysql_select_db("emp_agency") or die (mysql_error());

if($_SESSION['uid']) {

echo "You are already logged in <br>\n";
} else {

?>

	<form method="POST" action="login3.php">
	<table border="0" style="font-size: 15px; font-family: Tahoma; border: 1px solid black;"><TABLE>
	<TR>
		<TD>Username:</TD>
		<TD><input type="text" name="username" value="<?php echo $_POST ['username']; ?>"></TD>
	</TR>
	<TR>
		<TD>Password:</TD>
		<TD><input type="password" name="password" value="<?php echo $_POST ['password']; ?>"></TD>
	</TR>
	<TR>
		<TD colspan="2" align="center"> <input type="submit" name="submit" value="login"></TD>
	</TR>
	</TABLE>
	</form>

<?php

if($_POST['submit'])	{
	$curnum = 0;

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

	if(!$username)	{
		$curnum ++;
		echo $curnum . ". You need to enter a username!<br>\n";
				}

				if(!$password)	{
					$curnum ++;
					echo $curnum . ". You need to enter a password|<br>\n";
				}

				$sql = "SELECT * FROM user WHERE username='".$username."'";
				$res = mysql_query($sql) or die(mysql_error());
				$row = mysql_fetch_assoc($res);
				if(isset($username) && isset($password))	{

					if(mysql_num_rows($res) == 0)	{
						$curnum ++;
						echo $curnum . ". The username '<b>".$username."</b>' does not exist<br>\n";
					}

					if(mysql_num_rows($res) == 1)	{
						//the username does not exist

						if($password != $row['password'])	{
							$curnum ++;
							echo $curnum .". Wrong password,br.\n";
						}

						if($curnum == 0)	{
							$_SESSION['uid'] = $row['id'];
						}
					}
				}
}

?>

</BODY>
</HTML>

Link to comment
https://forums.phpfreaks.com/topic/127358-login-form-help/
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.