LOGIN HELP! Pls

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jinx11
Forum Newbie
Posts: 2
Joined: Tue Nov 29, 2011 4:42 pm

LOGIN HELP! Pls

Post by jinx11 »

:crazy:
im working with my login and i don't know what my error is, i dont get any error when i run my login...
here's my code, please kinda look at whats the problem here..!! thanks!

Code: Select all


<?php
                    session_start();
					include_once("connect.php");
					
					if(isset($_POST['submit']))
					{
					$idno=$_POST[idno];
					$pass=$_POST[pass];
					
			$login=mysql_query("Select * from register where idno='$idno' and password='$pass'")or die (mysql_error());
			
				if(mysql_num_rows($login)==0)
				{
					$msg="invalid";
				}
					else {
					$_SESSION[idno]=$idno;
					header("location: adminpage.php");
					}
					}
					?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form action="testlog.php" method="get">

idno<input name="idno" type="text" />
pass<input name="pass" type="text" />

<input name="submit" type="submit" />a
</form>
</body>
</html>
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: LOGIN HELP! Pls

Post by social_experiment »

Code: Select all

<?php
     $idno=$_POST[idno];
     $pass=$_POST[pass];
     // should be
     $idno = $_POST['idno'];
     $pass = $_POST['pass'];
?>
You're forgetting the quotation marks in the post variables; same goes for the $_SESSION variable ($_SESSION['idno'])
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: LOGIN HELP! Pls

Post by Celauran »

You also appear to be storing passwords as plain text, which is a bad idea, nor are you escaping user input, which can end in tears.
Post Reply