Jump to content

Duplicated entries on DDBB???


Perfidus

Recommended Posts

Hi there, I'm using a form done in flash to do a login, everything seems to work fine but when I check the DDBB I find that all the entries for login are duplicated, can you tell me if the PHP is ok so I can focus in the Flash app to see what's wrong in there?

You will see that there's also a pic upload, this process doesn't duplicate at all...

if (isset($_FILES['Filedata']))
{ 
$user = $_POST['user'];
$pass = $_POST['pass'];
$sql = "SELECT * FROM users WHERE user = '$user' AND pass = '$pass'";
$rs = mysql_query($sql);
if (mysql_num_rows($rs)==0)
{
	header("Location: login_home.php?login=0"); 
	mysql_close($link);		
}
else
{
	$ip = $_SERVER['REMOTE_ADDR'];  
	$ssql = "SELECT * FROM valid_ip WHERE ip = '$ip'";
	$rss = mysql_query($ssql);
	if (mysql_num_rows($rss)==0)
	{
		header("Location: login_home.php?login=0"); 
		mysql_close($link);
		return false;
	}
	else
	{
		session_start();
		$session = session_id();
		$_SESSION['user'] = $user;
		$_SESSION['ip'] = $ip;
		$_SESSION['session'] = $session;
		$code_ref = $_POST['coderef'];
		$rec_ref = mysql_result($rs, 0, 'rec_ref');
		$thequery = sprintf ("
		INSERT INTO
		access_control
		(
			date,
			rec_ref,
			code_ref
		)
		VALUES
		(
			'%s',
			'%s',
			'%s'
		);
		",
		date("Y-m-d"),
		$rec_ref,
		$code_ref		
		);
		$TEMP_FOLDER = 'pics/';
		$fulldate = date("Y_m_d_H_i_s");
		$new_name = $rec_ref."_".$fulldate;
		$filePath = $TEMP_FOLDER.$new_name.'.jpg';
		move_uploaded_file($_FILES['Filedata']['tmp_name'], $filePath);		
		if(mysql_query($thequery))
		{
			header("Location: login_home.php?login=true"); 

		}
                        else
                        {
                                header("Location: login_home.php?login=error"); 
                        }
	}
}
}
else
{
header("Location: login_home.php?login=2"); 
mysql_close($link);	
}

Link to comment
https://forums.phpfreaks.com/topic/174287-duplicated-entries-on-ddbb/
Share on other sites

So, is this php ok or is there something crazy on it?

Does the problem comes from Flash app?

Why the image uploading doesn't duplicate if the code is really executed twice?

 

There's a function in the code, I also add it in here for your consideration:

function getDataFromRef($reference, $criterium, $data, $table)
{
$sql = "SELECT $data FROM $table WHERE $reference = '$criterium'";
$rs = mysql_query($sql) or die(mysql_error() . "<br>$sql");
if(mysql_num_rows($rs)!=0)
{
	$data = mysql_result($rs, 0, $data);
	return $data;
}
else
{
	return false;		
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.