Jump to content

[SOLVED] Don't upload image more than once.


bytesize

Recommended Posts

This code is in form.php. The id_number is added to customer_id column in the photos table when the form is submitted. The id_number is automaticaly generated.

<input name="photo[customer_id]" size="40" type="hidden" value="<?php echo $_POST['id_number']; ?>" />

Let's say 4P2792Q893421 was posted into the database.

 

This code is in index.php and checks the database customer _id column for a match from id_number. If found, exit;,  if not found, add the values to the database. 

As you can see, I manualy inserted the id_number into the code. It's checking the column customer_id and finds a match which in turn exits to index.php.

$same_number= mysql_query("select id from photos where customer_id= '4P2792Q893421'"); 
$duplicate = mysql_num_rows($same_number);
	if ($duplicate > 0)
	{
	header("Location: index.php");
	exit();
	}

 

I tried to POST the id_number in this example and it doesn't work. What's wrong?

$same_number= mysql_query("select id from photos where customer_id= ''$_POST[id_number]'"); 
$duplicate = mysql_num_rows($same_number);
	if ($duplicate > 0)
	{
	header("Location: index.php");
	exit();
	}

 

Link to comment
https://forums.phpfreaks.com/topic/159473-solved-dont-upload-image-more-than-once/
Share on other sites

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.