Blank Page with execution of script

Hey there,

when i try to execute this script it returns with just a blank page, non of the message variables are echoed, not even an error.


if($_POST['submitted'] == 'yes'){

	if(empty($_POST['email']) || $_POST['email'] == ''){
		$error .= "<span class=\\"error\\"><p>You need to enter your email</p></span>";
	}
	else{
		$email = $clean->text($_POST['email']);
	}


	if(empty($_POST['password']) || $_POST['password'] == ''){
		$error .="<span class=\\"error\\"><p>You need to enter your password</p></span>";
	}

	if(isset($error)){
				echo $error;
	}

	else{
		$query = "SELECT id,farmName,level,salt1,salt2,password FROM users WHERE email = :email";

		$email = $clean->text($_POST['email']);
		$rawPass = $clean->text(hash('sha256',$_POST['password']));

		$values = array('email' => $email);

		try {
		$lookUp = $pdo->prepare($query);
		$s = $lookUp->execute($values);
			
		} catch (PDOException $e) {
			$message = "There has been an error trying to login in::: {$e->getMessage()}";
			$title = "Error!";		
		}

		 $row = $s->fetch();
    	if($row[0] > 0){
    		if($row['salt1'].$rawPass.$row['salt2'] == $row['password'])
    		{
        		$_SESSION['email'] = $row['email'];
            	        $_SESSION['id'] = $row['id'];
            	        $_SESSION['name'] = $row['name'];
            	        $_SESSION['level'] = $row['level'];
            	        $_SESSION['farmname'] = $row['farmname'];
            }
			$message =  "You have been logged in!";
			$title = "Logged in!";
            }
        else {
        	$message = "Password or email was wrong";
        	$title =  "There was an error";
        }
	}
}

session_start() is the first thing after php opening tags. So that leads me to belive it is an error with the selection of the data it’s self ( am i on the right track?)

Thanks again so much :slight_smile:

I would suspect this line: if($_POST[‘submitted’] == ‘yes’){

Try putting this print_r($_POST); at the top of your code before if($_POST[‘submitted’] == ‘yes’){

Hey there, that prints an array right? And if($_POST[‘submitted’] == ‘yes’){ is good, because the hidden filed is getting passed along. ( i also checked using the print_r function)

Yes print_r($_POST); will display an array of all your post variables - so when you run the code with that in you should have a value for submitted, email and password?

Try changing this


if(empty($_POST['email']) || $_POST['email'] == ''){

To this:


if(empty($_POST['email']) || ($_POST['email'] == '')){