SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2012
    Posts
    99
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    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.

    PHP Code:
    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

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,435
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    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'){

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2012
    Posts
    99
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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)

  4. #4
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,435
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    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
    PHP Code:
    if(empty($_POST['email']) || $_POST['email'] == ''){ 
    To this:
    PHP Code:
    if(empty($_POST['email']) || ($_POST['email'] == '')){ 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •