bytesize Posted May 24, 2009 Share Posted May 24, 2009 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(); } Quote Link to comment https://forums.phpfreaks.com/topic/159473-solved-dont-upload-image-more-than-once/ Share on other sites More sharing options...
waynew Posted May 24, 2009 Share Posted May 24, 2009 $id_num = mysql_real_escape_string($_POST['id_number']); $same_number= mysql_query("select id from photos where customer_id= '$id_num'"); $duplicate = mysql_num_rows($same_number); if ($duplicate > 0){ header("Location: index.php"); exit(); } Quote Link to comment https://forums.phpfreaks.com/topic/159473-solved-dont-upload-image-more-than-once/#findComment-841201 Share on other sites More sharing options...
bytesize Posted May 24, 2009 Author Share Posted May 24, 2009 Thanks for the quick reply. I tried your code. It's not working. It's probably me! I will continue to work with your code and report back later. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/159473-solved-dont-upload-image-more-than-once/#findComment-841235 Share on other sites More sharing options...
bytesize Posted May 25, 2009 Author Share Posted May 25, 2009 It works! Thank you Quote Link to comment https://forums.phpfreaks.com/topic/159473-solved-dont-upload-image-more-than-once/#findComment-841475 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.