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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

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.