PDA

View Full Version : Error: You have left fields blank


malcome_thompson
26th March 2008, 23:28
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.

o.meyer
27th March 2008, 04:08
Hi,

try this:

<?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

malcome_thompson
27th March 2008, 12:17
Awesome. That worked perfectly dude. Thank you very much:)

topdog
27th March 2008, 16:02
Remember to sanitize user input before using it. Otherwise your code will be vulnerable