Jump to content

Login script


unistake

Recommended Posts


Hi all again,

 

This script was working perfectly but I have not got a clue what changed in it or how and can not seem to find the problem.

 

The connection works, email and password variables match the mysql databases so must be my Syntax.

 

appreciate if you can help.

 

<?php

include("../cxn.php");

$sql = "SELECT password FROM Members WHERE email='$_POST[email]'";
$result = mysqli_query($cxn,$sql)
or die ("Couldn't execute query1");

$num = mysqli_num_rows($result);
if ($num >0) // Login Name found 
{
	$sql = "SELECT * FROM Members WHERE email='$_POST[email]' AND password=md5('$_POST[password]')";
	$result2 = mysqli_query($cxn,$sql)
		or die ("Couldn't execute query2");
	$num2 = mysqli_num_rows($result2);
	if ($num2 > 0) // password correct
		{
			session_start();
			$_SESSION['auth']="yes";
			$_SESSION['logname'] = $_POST['email'];
			$logname = $_SESSION['logname'];
			$today = date("Y-m-d h:i:s");
			$sql = "INSERT INTO Login (email,loginTime)
					VALUES ('$logname', '$today')";
			$result = mysqli_query($cxn,$sql)
				or die ("Can't execute insert query");
			echo "you have logged in!";
			header("Location: ../$_POST

");
		}
	else 
		{
			$message = "The email address, '$_POST[email]' is registered, but you have not entered the correct password! Please try again.<br>";
			include("../login.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.