joshgarrod Posted January 22, 2009 Share Posted January 22, 2009 i have a system where people can submit adverts and when they do so they also enter a password, so if their item is sold they can view their advert and enter their password into a form on it and if they match up delete the record. At the moment i am seeing the url in address bar but the page comes up blank when you submit the password. Advert view with delete form: <?php $password = $info ['password']; $ref = $info ['ref']; echo "<h2>Is this your item, and has it been sold?</h2>"; echo "<p>Simply type the password you entered when submitting the item and it will be removed from our website instantly.</p>"; echo "<form method=\"POST\" action=\"delete_item.php?ref=".$info['ref']."\"> Password: <input type=\"text\" name=\"password_entered\" size=10> <input name=\"hidden_password\" type=\"hidden\" value=\"$password\" /> <input name=\"id_delete\" type=\"hidden\" value=\"$ref\" /> <input type=\"submit\" value=\"Sold\"> </form>"; ?> delete item: <?php $con = mysql_connect("serv","usr","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); $id=$_GET['id_delete']; $password_entered = $_GET['password_entered']; $hidden_password = $_GET['hidden_password']; if ($password_entered == $hidden_password) { mysql_query("delete from classifieds where ref='$id'"); mysql_close(); header("location:thankyou.html"); } else { echo "You entered the wrong password"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/141931-solved-delete-record-dependant-upon-conditon-met/ Share on other sites More sharing options...
landavia Posted January 22, 2009 Share Posted January 22, 2009 and what the problem sry.. english is not my primary languages >>header("location:thankyou.html"); is thankyour.html exits? and plz.. add exit() after the header like this header("location:thankyou.html"); exit(); Quote Link to comment https://forums.phpfreaks.com/topic/141931-solved-delete-record-dependant-upon-conditon-met/#findComment-743153 Share on other sites More sharing options...
joshgarrod Posted January 22, 2009 Author Share Posted January 22, 2009 ok, thanks, i added exit(); after header and it now redirects me to the thankyou.html but the it does not delete the record. and i just realised it goes to the thank you page even if password is wrong Quote Link to comment https://forums.phpfreaks.com/topic/141931-solved-delete-record-dependant-upon-conditon-met/#findComment-743167 Share on other sites More sharing options...
landavia Posted January 22, 2009 Share Posted January 22, 2009 are you tried mysql_error()? i believe there an error ^^ i know the error >>"delete from classifieds where ref='$id'" u should type "delete from classifieds where ref='$_POST[id]'" Quote Link to comment https://forums.phpfreaks.com/topic/141931-solved-delete-record-dependant-upon-conditon-met/#findComment-743180 Share on other sites More sharing options...
joshgarrod Posted January 22, 2009 Author Share Posted January 22, 2009 it still doesn't work with that line, my if statement doesn't seem to be checking the two variables properly as you can enter the wrong password and it still goes to thankyou.html but does not delete the record Quote Link to comment https://forums.phpfreaks.com/topic/141931-solved-delete-record-dependant-upon-conditon-met/#findComment-743192 Share on other sites More sharing options...
deansatch Posted January 22, 2009 Share Posted January 22, 2009 change all your $_GET's to $_POST's Quote Link to comment https://forums.phpfreaks.com/topic/141931-solved-delete-record-dependant-upon-conditon-met/#findComment-743197 Share on other sites More sharing options...
joshgarrod Posted January 22, 2009 Author Share Posted January 22, 2009 i have tried that too and it has no effect... Quote Link to comment https://forums.phpfreaks.com/topic/141931-solved-delete-record-dependant-upon-conditon-met/#findComment-743199 Share on other sites More sharing options...
joshgarrod Posted January 22, 2009 Author Share Posted January 22, 2009 sorted it! thanks for your help guys Quote Link to comment https://forums.phpfreaks.com/topic/141931-solved-delete-record-dependant-upon-conditon-met/#findComment-743204 Share on other sites More sharing options...
deansatch Posted January 22, 2009 Share Posted January 22, 2009 check the source code of your form before submitting to see if the $ref has a value. Also add "or die(mysql_error())" to your db query Quote Link to comment https://forums.phpfreaks.com/topic/141931-solved-delete-record-dependant-upon-conditon-met/#findComment-743205 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.