Grow your CSS skills. Land your dream job.

PHP page remains blank

  • # May 2, 2012 at 6:19 am

    Hello everyone!

    I’m having a bit of a problem with a php validation script for my login form on my webiste.

    Im sure the problem may come as simple to some of you but ive been banging my head for a few hours on it and just cant figure it out. Help would be appreciated :-)

    The login and validation work perfectly on my localhost. However, when i go to test on my remote server the validation gets stuck on the login_do page and when it should, infact, redirect me back to the page where the form is and tell me the outcome of the process. As in, were there any errors or was the registration sucessfull .

    If it helps you can go on to http://www.skillsden.net/register_page.php and type in a load of gibberish in the username and login fields and see for yourself.

    So, i have the following form:






  • *




  • *






  • Which links to login_do where simple validation is made:

    < ?php
    ob_start();
    ?>

    < ?php

    if (isset($_POST["username"], $_POST["password"])){

    $username = strip_tags(htmlentities($_POST["username"]));

    $password = strip_tags(htmlentities($_POST["password"]));

    if ($username && $password){

    $connect =mysql_connect("localhost", "root", "")or die($error);
    mysql_select_db("phplogin")or die($error);

    $query = mysql_query("SELECT * FROM users WHERE username= '$username'");

    $numrows = mysql_num_rows($query);

    if ($numrows!=0){

    while($row=mysql_fetch_assoc($query)){

    $dbusername = $row ["username"];
    $dbpassword = $row ["password"];
    $activated = $row ["activated"];

    //Checks for activated email account!

    if($activated == '0')
    {

    header("location:register_page.php?status=EmailActivation");
    die();
    }

    }

    if($username == $dbusername && md5($password) == $dbpassword){

    header("Location:loginsucess.php");

    $_SESSION=$user;
    }

    else
    header("location:register_page.php?status=IncorrectPasswordUsername");
    die();
    }

    else
    header("location:register_page.php?status=NoSuchUser");
    die();

    }

    else
    header("location:register_page.php?status=NoInfoGiven");
    die();
    }

    ?>

    The errors are then returned on the page where the form is – for more usability via $_GET. Code is below:

    < ?php

    if(isset($_GET))
    {
    if ($_GET == "EmailActivation")
    {
    echo " You have not yet activated your account";
    }
    if ($_GET == "IncorrectPasswordUsername")
    {
    echo " Password or username is incorrect";
    }
    if ($_GET == "NoSuchUser")
    {
    echo "Sorry, SkillsDen couldnt find you!";
    }

    if ($_GET == "NoInfoGiven")
    {
    echo "Please enter you login details!";
    }

    }

    ?>

    [/code]

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".