Jump to content

My PHP Login :(


mtayloronline

Recommended Posts

Hi Guys, Im new here, Can someone please help me and tell me why my PHP code isn't working :/

 

<?php
session_start();
$sql = mysql_connect('localhost', 'putwriter_login', 'MyPassHere');

if(!$sql){
die(mysql_error());
}
mysql_select_db('putwriter_college');


$user = mysql_real_escape_string($_POST['user']);
$pass = mysql_real_escape_string($_POST['password']);


$sqlSel = mysql_query("SELECT * FROM `putwriter_college`.`Login` WHERE `EmailAddress`=$user AND `Password`=$pass LIMIT 1;");
while($row = mysql_fetch_assoc($sqlSel)){

echo 'Im probably not here';

if(($row['EmailAddress'] == $user) && ($row['Password'] == $pass)){
	$_SESSION['loggedIn'] = md5('someSessId');
	echo "<meta http-equiv='refresh' content='2;url=./home.php'>";
}else{
	die('FAIL');
}
}

?>

 

This is what I get :

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/putwriter/domains/putwriter.co.uk/public_html/login.php on line 16

Link to comment
Share on other sites

Your query structure is ok, it might be one of the variables in the query...

 

$user = mysql_real_escape_string($_POST['user']);
$pass = mysql_real_escape_string($_POST['password']);

var_dump($user);
var_dump($pass);

 

Debug a bit, lets see the variables content... Both are string?

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.