dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Login script help

  1. #1
    Join Date
    Oct 2012
    Posts
    15

    Angry Login script help

    alright, I'm copying this tutorial to create a login page

    http://www.9lessons.info/2009/09/php...e-example.html

    and it starting to piss me off, and I dont know why its not redirecting to the page I want to redirect

    and this is my script for the login page

    include "database-connection.php";
    session_start();

    if($_SERVER["REQUEST_METHOD"] == "POST")
    {
    // username and password sent from Form
    $myusername=addslashes($_POST["username"]);
    $mypassword=addslashes($_POST["password"]);

    $sql="SELECT id FROM Account_Info WHERE UserName='$myusername' and Password='$mypassword'";
    $result=mysql_query($sql);
    $row=mysql_fetch_array($result);

    $count=mysql_num_rows($result);


    // If result matched $myusername and $mypassword, table row must be 1 row
    if($count==1)
    {
    session_register("myusername");


    header("location: http://www.adamistheschmidt.com/bkcms/home.php");

    }
    else
    {
    $error="Your Login Name or Password is invalid";
    }
    }


    thank you for all of your help in advance

  2. #2
    Join Date
    Jul 2010
    Posts
    66
    • The "redirection" is clearly in the header function. Have you verified that page exists: copy the entire URL into the browser address and click...you should not get a "page not found/404" error
    • If the flow of code does not get to the header function, that means PHP found an error in execution at an earlier point. It usually sends the error to standard output (to your browser in the HTTP response. What does that output say?


    There are many points in your code where PHP execution errors are possible. You must not only resolve all PHP errors, but also warnings and notices...they are usually problems that should be errors.

    • is your HTTP request what it should be?? Did you set up a form (HTML form markup) with textbox elements that are named 'username' and 'password' that are transmitted with the click? Did you use the POST instead of GET method? The script wants POST.
    • is your MySQL database set up properly?
    • you have an include file: was it found?? using the require() function instead of include would given an error rather than perhaps a notice or warning.


    I have no idea how much you know about HTML markup, CSS, Javascript, PHP, or MySQL, which will be essential to your successful use of what you likely want to do.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles