bytesize Posted May 26, 2009 Share Posted May 26, 2009 This code is in form.php. The POST txn_id is added to the paypal_id column in the photos table when the form is submitted. <input name="photo[paypal_id]" size="40" type="hidden" value="<?php echo $_POST['txn_id']; ?> I use this code in index.php but there is no POST to this page. So it doesn't work! $id_num = mysql_real_escape_string($_POST['txn_id']); $rs_duplicates = mysql_query("select id from photos where paypal_id = '$id_num'"); $duplicates = mysql_num_rows($rs_duplicates); if ($duplicates > 0) { header("Location: index.php"); exit(); } I would like to check the column paypal_id for the insertion of txn_id that came from the form. If there's a match then exit. This would stop the user from clicking back and uploading the form and image again. Can someone help me with this? Quote Link to comment Share on other sites More sharing options...
Brian W Posted May 26, 2009 Share Posted May 26, 2009 your going to need to explain what you need again, more clearly so that we all can understand your goal. Some things to include (not that you've missed these) is: What you want the script to do, what does it do now, and ALL applicable code which should also be the code for the submitting form in most cases. Am I correct that you are attempting to prevent double uploads? Quote Link to comment Share on other sites More sharing options...
bytesize Posted May 26, 2009 Author Share Posted May 26, 2009 Yes! The user pays to submit the photo. When they return from PayPal, some data is posted to the form. index.php case "create": $id_num = mysql_real_escape_string($_POST['txn_id']); $rs_duplicates = mysql_query("select id from photos where paypal_id='$id_num'"); $duplicates = mysql_num_rows($rs_duplicates); if ($duplicates > 0) { header("Location: index.php"); exit(); } if(is_jpeg($_FILES['photo']['type']['file']) and is_valid_file_size($_FILES['photo']['size']['file']) and is_uploaded_file($_FILES['photo']['tmp_name']['file']) and is_minimum_width_height($_FILES['photo']['tmp_name']['file']) and is_maximum_width_height($_FILES['photo']['tmp_name']['file']) ) { if(is_fields_filled_out($_POST['photo'])) { $_POST['photo']['theme_id'] = $this_weeks_theme['id']; $photo_id = create_photo($_POST['photo']); copy($_FILES['photo']['tmp_name']['file'], './photos/'.$photo_id.'.jpg'); $notice = "Successfuly created photo."; } else { $warning = "Click back and fill in all fields."; } } else { $warning = "Click back, error uploading file. Please make sure your file is a jpeg or gif and less than 1MB in size."; } break; } form.php <?php if(!empty($_POST)): ?> <p>Hello, <b><?php echo $_POST['first_name']; ?> <?php echo $_POST['last_name']; ?></b>, thank you for your order. Please check your email <b><?php echo $_POST['payer_email']; ?></b> for your receipt.</p> <h1>Submit Your Photo</h1> <p>Fill in the form and your Photo will be added to the Album of this web site!</p> <form action="index.php?view=create" method="post" enctype="multipart/form-data"> <fieldset> <div> <label><b>Web Address:</b></label> <input name="photo[discuss_url]" size="40" type="text" value="http://" class="textfield" /> <br/> <label>This is the link to your web site. Please prefix with: http://</label> </div> <div> <label><b>Attach Photo</b></label> <input name="photo[file]" type="file" class="textfield" /><br/> </div> <input name="photo[paypal_id]" size="40" type="hidden" value="<?php echo $_POST['txn_id']; ?>" /> <input type="submit" name="submit" value="Upload Photo" onSubmit='return clearForm(form_new)' /> </fieldset> </form> <?php endif; ?> create.php <?php header("Location: index.php"); ?> Quote Link to comment Share on other sites More sharing options...
Brian W Posted May 26, 2009 Share Posted May 26, 2009 Your switch is on $_GET['view'], correct? Here is a slightly modified version case "create": $id_num = mysql_real_escape_string($_POST['txn_id']); if($id_num > "") { $rs_duplicates = mysql_query("select id from photos where paypal_id='$id_num'") or die("MySql Error:<br>".mysql_error()); $duplicates = mysql_num_rows($rs_duplicates); if ($duplicates > 0) { header("Location: index.php"); exit(); } } if(is_jpeg($_FILES['photo']['type']['file']) and is_valid_file_size($_FILES['photo']['size']['file']) and is_uploaded_file($_FILES['photo']['tmp_name']['file']) and is_minimum_width_height($_FILES['photo']['tmp_name']['file']) and is_maximum_width_height($_FILES['photo']['tmp_name']['file']) ) { if(is_fields_filled_out($_POST['photo'])) { $_POST['photo']['theme_id'] = $this_weeks_theme['id']; $photo_id = create_photo($_POST['photo']); copy($_FILES['photo']['tmp_name']['file'], './photos/'.$photo_id.'.jpg'); $notice = "Successfuly created photo."; } else { $warning = "Click back and fill in all fields."; } } else { $warning = "Click back, error uploading file. Please make sure your file is a jpeg or gif and less than 1MB in size."; } break; } Quote Link to comment Share on other sites More sharing options...
bytesize Posted May 26, 2009 Author Share Posted May 26, 2009 I'm not receiving a post to index.php. The post returns to form.php. PayPal puts its data into column paypal_trans_id in table orders. When the form is submitted, the post is put into table photos column txn_id. form.php <input name="photo[paypal_id]" size="40" type="hidden" value="<?php echo $_POST['txn_id']; ?>" /> It seems like the only way this will work is to check if there is a match between table orders.paypal_trans_id and photos.paypal_id and put this query inside the index.php file. Something like the example below. I know the code is incorrect, but you get the idea, right? index.php $rs_duplicates = mysql_query("select from photos.paypal_id = orders.paypal_trans_id"); $duplicates = mysql_num_rows($rs_duplicates); if ($duplicates > 0) { header("Location: index.php"); exit(); } Quote Link to comment 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.