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
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;		
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.