Jump to content

Whats wrong... Login problems


ccrevcypsys

Recommended Posts

so i have this login page and i was wondering why it isnt working. Nothing is parsing. Can someone look at this and let me know whats going on?

<?php
if($_POST['submit']){

$errors = array();

if(empty($_POST['email'])){
	$errors[]= 'You forgot the email addres...';
}else{
	$e = escape_data($_POST['email'];
}

if(empty($_POST['password'])){
	$errors[] = 'You didn′t put in a password';
}else{
	$p = escape_data($_POST['password']);
}

if(empty($errors)) {
	$query = "SELECT customer_id, firstName FROM `customer` WHERE email = '".$e."' AND password=SHA('".$p."')";
	$result = @mysql_query($query);
	$row = mysql_fetch_array($result, MYSQL_NUM);

	if($row){
		setcookie('customer_id', $row[0]);
		setcookie('firstName', $row[1]);
		$url= 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
		if((substr($url, -1) == '/') || (substr($url, -1)=='\\') ) {
			$url = substr ($url, 0 , -1);
		}
		$url = '/loggedin.php';
		header("Location: $url");
		exit();
	}else{
		$errors[] = 'The Email Address And Password You Entered Do Not Match Those On File.';
		$errors[] = mysql_error().'<br /><br /> Qury:'.$query;
	}
	mysql_close();
}else{
$errors = NULL;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/82709-whats-wrong-login-problems/
Share on other sites

First problem would be the syntax error here:

 

<?php
if($_POST['submit']){

$errors = array();

if(empty($_POST['email'])){
	$errors[]= 'You forgot the email addres...';
}else{
	$e = escape_data($_POST['email'];
}

 

you need to have

 

<?php
if($_POST['submit']){

$errors = array();

if(empty($_POST['email'])){
	$errors[]= 'You forgot the email addres...';
}else{
	$e = escape_data($_POST['email']);
}

 

You were missing the closing ")" with the escape_data.  That might not be the only issue.  Once you fix that let me know and I'll continue looking.

it still isnt loading anything

even if i get rid of those it still wont load anything

 

so now i just have this

if($_POST['submit']){
$errors = array();

if(empty($errors)) {
	$query = "SELECT customer_id, firstName FROM customer WHERE email = '$e' AND password=SHA('$p')";
	$result = @mysql_query($query);
	$row = mysql_fetch_array($result, MYSQL_NUM);

	if($row){
		setcookie('customer_id', $row[0]);
		setcookie('firstName', $row[1]);
		$url= 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
		if((substr($url, -1) == '/') || (substr($url, -1)=='\\') ) {
			$url = substr ($url, 0 , -1);
		}
		$url .= '/loggedin.php';
		header("Location: $url");
		exit();
	}else{
		$errors[] = 'The Email Address And Password You Entered Do Not Match Those On File.';
		$errors[] = mysql_error().'<br /><br /> Qury:'.$query;
	}
	mysql_close();
}else{
$errors = NULL;
}

if($_POST['submit']){

 

If this doesn't turn out TRUE, then your else clause just nullifies $errors, and nothing would be output.

 

Is there more to this script? If not, then $_POST['submit'] isn't being submitted with a value. Try a print_r($_POST) at the top of the script to see what is being POSTed.

 

PhREEEk

Archived

This topic is now archived and is closed to further replies.

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