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 142.68.44.81] PHP Notice: Undefined index: email in /var/www/vhosts/www.dungeonofchaos.com/httpdocs/gameconfig.php on line 3, referer: http://www.dungeonofchaos.com/check.php
    [client 142.68.44.81] PHP Notice: Undefined index: password in /var/www/vhosts/www.dungeonofchaos.com/httpdocs/gameconfig.php on line 4, referer: http://www.dungeonofchaos.com/check.php

    The first 5 lines of code are:

    <?php
    session_start();
    $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

    Hi,

    try this:

    Code:
    <?php
    session_start();
    
    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,

    Olli
     
    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 HowtoForge Supporter

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

Share This Page