Jump to content

Login code don't work


frozie92

Recommended Posts

H im new here, im getting error on line 69 and i cant login using the code :( plz help, The user exist but dont know why its using email function for

 

Error:

Notice: Undefined index: email in C:\xampp\htdocs\test\login.php on line 69

That user does not exist. Click Here to Register

 

<?php 

// Connects to your Database 

mysql_connect("localhost", "root", "guardian92") or die(mysql_error()); 

mysql_select_db("issp") or die(mysql_error()); 


//Checks if there is a login cookie

if(isset($_COOKIE['issp.com']))


//if there is, it logs you in and directes you to the members page

{ 
	$username = $_COOKIE['issp.com']; 

	$pass = $_COOKIE['issp.com'];

	 	$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());

	while($info = mysql_fetch_array( $check )) 	

		{

		if ($pass != $info['password']) 

			{

			 			}

		else

			{

			header("Location: members.php");



			}

		}

}


//if the login form is submitted 

if (isset($_POST['submit'])) { // if form has been submitted



// makes sure they filled it in

	if(!$_POST['username'] | !$_POST['pass']) {

		die('You did not fill in a required field.');

	}

	// checks it against the database



	if (!get_magic_quotes_gpc()) {

		$_POST['email'] = addslashes($_POST['email']);

	}

	$check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error());



//Gives error if user dosen't exist

$check2 = mysql_num_rows($check);

if ($check2 == 0) {

		die('That user does not exist. <a href=index.php?page=Signup>Click Here to Register</a>');

				}

while($info = mysql_fetch_array( $check )) 	

{

$_POST['pass'] = stripslashes($_POST['pass']);

	$info['password'] = stripslashes($info['password']);

	$_POST['pass'] = md5($_POST['pass']);



//gives error if the password is wrong

	if ($_POST['pass'] != $info['password']) {

		die('Incorrect password, please try again.');

	}
else 

{ 


// if login is ok then we add a cookie 

	 $_POST['username'] = stripslashes($_POST['username']); 

	 $hour = time() + 3600; 

setcookie(ID_my_site, $_POST['username'], $hour); 

setcookie(Key_my_site, $_POST['pass'], $hour);	 



//then redirect them to the members area 

header("Location: members.php"); 

} 

} 

} 

else 

{	 



// if they are not logged in 

?> 

<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> 

<table border="0"> 



<tr><td width="75">Username:</td><td colspan="2"> 

<input type="text" name="username" maxlength="40"  class="textboxstyle"> 

</td></tr> 

<tr><td>Password:</td><td colspan="2"> 

<input type="password" name="pass" maxlength="50"  class="textboxstyle"> 

</td></tr> 

<tr><td align="right"> </td>
   <td width="143" align="right"><input type="submit" name="submit" value="Login" />     <input type="reset" name="Reset" value="Reset" /></td>
   <td width="1" align="right"> </td>
</tr> 

</table> 

</form> 

<?php 

} 



?>

Link to comment
Share on other sites

That code has so many things wrong with it, too many to even bother...and it looks like outdated code on top of that...I suggest you go find a newer login script to use.

 

Also, this isn't a regex question.

 

ok can u recommend a login / resignation system and when login it goes to members.php ?

Link to comment
Share on other sites

I have no idea what "resignation" means to you, so I can't really recommend a script for that.  Do you mean "logout"? Do you mean some kind of script to unregister?  Script to resign from a job or project or something?  Be more specific.

 

But anyways, there is no magic script out there that will magically work by just uploading it to your server.  You're going to have to write from scratch or integrate it with the rest of your site. 

 

No offense, but there are some pretty easy to spot/simple errors in the script that you posted, and if you are not proficient enough to have caught them, I don't think you will be able to write one from scratch yourself or even integrate an existing system with your site. 

 

There are plenty of login/membership system code tutorials out there; I suggest you start there instead of trying to find some prefab solution if you really want to do it yourself.  If not, then my best suggestion to you would be to hire someone to do it for you.

 

 

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.