Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2007
    Posts
    310
    Tokens
    0

    Default *** is this error all about ;S

    I have this code...

    Code:
    <?
    
    include "config.php";
    
    $username = $_POST['username'];
    $password = md5($_POST[password]);
    
    $info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $data = mysql_fetch_array($info);
    
    if($data[password] != $password) {
    
    echo "<META http-equiv=\"refresh\" content=\"3;URL=invalid.php\">";
    
    }else{
    
    $query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $user = mysql_fetch_array($query);
    
    setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
    setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
    
    echo ("<META http-equiv=\"refresh\" content=\"3;URL=index.php\">");
    
    }
    
    ?>
    When the login is invalid it goes to invalid page as it should but when the login is correct i get this error:

    Warning: Cannot modify header information - headers already sent by (output started at /home/pkskape/public_html/processlogin.php:9) in /home/pkskape/public_html/processlogin.php on line 46

    Warning: Cannot modify header information - headers already sent by (output started at /home/pkskape/public_html/processlogin.php:9) in /home/pkskape/public_html/processlogin.php on line 47
    Processing Login... If this page appears for more than 5 seconds click here...

    Moved by Mattps22004 (Forum Moderator) from Website Designing & Development: Please post in the correct forum next time, thanks .
    Last edited by Matt.; 01-08-2007 at 04:23 PM.

  2. #2
    Join Date
    Oct 2006
    Location
    Merseyside
    Posts
    2,335
    Tokens
    0

    Latest Awards:

    Default

    I think you posted the wrong code try posting invalid.php or index.php (i think the one above it index.php?)

  3. #3
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <?
    ob_start
    ();

    include 
    "config.php";

    $username $_POST['username'];
    $password md5($_POST[password]);

    $info mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $data mysql_fetch_array($info);

    if(
    $data[password] != $password) {

    echo 
    "<META http-equiv=\"refresh\" content=\"3;URL=invalid.php\">";

    }else{

    $query mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $user mysql_fetch_array($query);

    setcookie("id"$user[id],time()+(60*60*24*5), "/""");
    setcookie("pass"$user[password],time()+(60*60*24*5), "/""");

    echo (
    "<META http-equiv=\"refresh\" content=\"3;URL=index.php\">");

    }

    ?>
    U forgot the ob_start(); up the top mate. Have fun

  4. #4
    Join Date
    Jul 2007
    Posts
    30
    Tokens
    0

    Default

    You really ought to put some form of security on there..

    Just try a few simple things like addslashes() on your inputs.

  5. #5
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    *stipslashes()

  6. #6
    Join Date
    Jul 2005
    Posts
    1,653
    Tokens
    50

    Latest Awards:

    Default

    mysql_real_escape_string and stripslashes is what I always use. Write a function to clean the strings.

  7. #7
    Join Date
    May 2007
    Posts
    10,481
    Tokens
    3,140

    Latest Awards:

    Default

    also use sessions rather than cookies.. much more secure
    Chippiewill.


  8. #8
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Oh everyones talking bout protection. Well to stop html and everything else u wanna set up a function with stripslashes(); etc.

  9. #9
    Join Date
    Jul 2007
    Posts
    30
    Tokens
    0

    Default

    Quote Originally Posted by Invent View Post
    *stipslashes()
    Surely you want to add slashes before every single quote, BEFORE it goes into the database? And strip them when you're displaying the HTML?

Posting Permissions

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