Error: You have left fields blank

Discussion in 'Programming/Scripts' started by malcome_thompson, Mar 26, 2008.

  1. malcome_thompson

    malcome_thompson New Member

    In a game that I run, after you log in, it keeps saying You have left fields blank please relogin on any link within the game that you click. I checked my error logs, and am getting this message:

    [client] PHP Notice: Undefined index: email in /var/www/vhosts/ on line 3, referer:
    [client] PHP Notice: Undefined index: password in /var/www/vhosts/ on line 4, referer:

    The first 5 lines of code are:

    $email = $_REQUEST['email'];
    $password = $_REQUEST['password'];
    $dbh=mysql_connect ("localhost", "dungeono_DoC", "stone") or die ('I cannot connect to the database because: ' . mysql_error());

    Can anyone help? If I take out lines 3 and 4 completely, you can't even log in, but after you log in, and the check.php file tries to load another link, it gives the relogin message.
  2. o.meyer

    o.meyer ISPConfig Developer ISPConfig Developer


    try this:

    if( isset($_REQUEST['email']) && isset($_REQUEST['password']) ){
        $email = $_REQUEST['email'];
        $password = $_REQUEST['password'];
    Btw: I hope you escape $email and $password before you use it in the sql-query.

    Best regards,

    Last edited: Mar 27, 2008
  3. malcome_thompson

    malcome_thompson New Member

    Awesome. That worked perfectly dude. Thank you very much:)
  4. topdog

    topdog Active Member

    Remember to sanitize user input before using it. Otherwise your code will be vulnerable

Share This Page