SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot rrreview's Avatar
    Join Date
    Jul 2002
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    More login system problems

    Ok so I've been following this tutorial http://robouk.mchost.com/tuts/tutori...tutorial=login and I've slightly modified it. I get this error when I try to login.
    Warning: Cannot add header information - headers already sent by (output started at /home/snt/public_html/teamsik/run****.php:12) in /home/snt/public_html/teamsik/login.php on line 15

    Warning: Cannot add header information - headers already sent by (output started at /home/snt/public_html/teamsik/run****.php:12) in /home/snt/public_html/teamsik/login.php on line 19
    run****.php is just my database login information and the connection to the database. Let me show you login.php...
    PHP Code:
    <?php 
    include("run****.php" ); 
    /*This is were the actual log in takes place. We tell mysql to select the ID where the Name is exactly like the Name from the Form 
    where is Password is exactly like the encryption values of the password from the form.*/ 
    $sql "SELECT ID FROM " $Table " WHERE Name='" addslashes($_POST['Name']) . "' AND Password='" md5($_POST['Password']) . "' LIMIT 1"
    if(!(
    $result mysql_query($sql))) die(mysql_error()); 
    /*This is were we check the result. We check to see how many rows were in the result of the query. If there is 1 one row in the result, that means 
    there is one username with the right information, so that would mean they are logged in.*/ 
    if(mysql_num_rows($result) == 1) { 
    /*Here we set a cookie that tells if the user has logged in and set it to last for a day. The cookie is used on the members page to check 
    If they cookie is there they can see the page, if not they can't.*/ 

    setcookie("thecookievalueat8characterswithonlyuppercaselettersandnumbers"TRUEtime()+(3600 24)); 

    /*You could also do the header() here just like I explained before.*/ 
    header("Location: http://mywebsite.com/supersecretfolder/index.php");
    } else { 
    echo 
    "Login failure"

    ?>
    Now for the section of index.php...
    PHP Code:
    <?php 
    /*If the cookie isset then they are logged in, else the scripts dies and says they are not logged in.*/ 
    if(!isset($_COOKIE['thecookievalueat8characterswithonlyuppercaselettersandnumbers'])) {
    echo 
    " <div align=\"right\">
    <table width=\"190\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#333333\">
    <tr><td>
    <form action=\"login.php\" method=\"POST\">
    <img src=""\"images/right_memberlogin.gif\" alt=\"\" vspace=\"8\"><br>
    <font class=\"whitetext\"><b>&nbsp;USERNAME</b><br>
    <input type=\"text\" name=\"Name\" size=\"15\" style=\"font-family: Verdana; font-size: 8pt\"><br>
    <font class=\"whitetext\"><b>&nbsp;PASSWORD</b><br>
    <input type=\"password\" name=\"Password\" size=\"15\" style=\"font-family: Verdana; font-size: 8pt\">&nbsp;&nbsp;<input type=\"submit\" name=\"submit\" value=\"LOGIN\" style=\"font-family: Verdana; font-size: 8pt; font-weight: bold\">
    </font></form>"
    ;
    } else {
    echo (
    "congratulations, you are logged in." );
    }
    ?>
    If you could help me, I'd really appreciate it.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    check white space in anycode you include before setting cookie

  3. #3
    SitePoint Wizard Mike Borozdin's Avatar
    Join Date
    Oct 2002
    Location
    Edinburgh, UK
    Posts
    1,743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    put this to the first line of your code:
    PHP Code:
    ob_start (); 
    And this to the last one:
    PHP Code:
    ob_end_flush (); 


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
  •