Cetanu Posted July 17, 2009 Share Posted July 17, 2009 I think I completely massacred this form, but you know, I'm learning. I just want it to delete a user's account after they check yes or no... <fieldset style="padding: 10px;"> <legend>Delete Account: <?php echo "{$_SESSION['username']}"; ?></legend> <form action="daccount.php" method="get"> <input type="radio" name="yes" value="Delete Account"/>Yes<br/> <input type="radio" name="no" value="No"/>No<br/> <input type="submit" value="Submit" name="Submit"/> </form> </fieldset> <?php include "db.php"; if($_GET['Delete Account'] && $_GET['Submit']){ $sql = "DELETE FROM users WHERE `id`={$_GET['id']} AND `username`={$_SESSION['username']}"; $query = mysql_query($sql) or die(mysql_error()); echo " Hope you enjoyed MythScape. Sorry you un-registered."; echo "<a href=\"index.php\"> Click here </a> to Go Home"; } else{ echo "Not deleted!"; } ?> What it's doing is: -Allowing me to highlight yes AND no... -Echoing "Not Deleted" before anything is checked or submitted. -Not deleting the account. Quote Link to comment https://forums.phpfreaks.com/topic/166311-quick-form-help/ Share on other sites More sharing options...
xcoderx Posted July 17, 2009 Share Posted July 17, 2009 I think u have to add post method? Yes = ["yes"]; then if else statement aswel? Am not sure tho just thinking lol Quote Link to comment https://forums.phpfreaks.com/topic/166311-quick-form-help/#findComment-877004 Share on other sites More sharing options...
xcoderx Posted July 17, 2009 Share Posted July 17, 2009 Oopz my apology u have done that. Quote Link to comment https://forums.phpfreaks.com/topic/166311-quick-form-help/#findComment-877006 Share on other sites More sharing options...
Cetanu Posted July 17, 2009 Author Share Posted July 17, 2009 That's okay I think I've tried everything. It's pro'lly just a stupid little mistake. Quote Link to comment https://forums.phpfreaks.com/topic/166311-quick-form-help/#findComment-877011 Share on other sites More sharing options...
didgydont Posted July 17, 2009 Share Posted July 17, 2009 <?php include "db.php"; if($_POST['yes']=="Delete Account" ){ mysql_query("DELETE FROM users WHERE id='$_POST[id]' AND username='$_SESSION[username]' "); echo " Hope you enjoyed MythScape. Sorry you un-registered."; echo "<a href=\"index.php\"> Click here </a> to Go Home"; } else{ echo "Not deleted!"; } ?> but you need to add the id as a hidden input to the form <input type="hidden" name="id" value="theidhere"/> Quote Link to comment https://forums.phpfreaks.com/topic/166311-quick-form-help/#findComment-877014 Share on other sites More sharing options...
Cetanu Posted July 17, 2009 Author Share Posted July 17, 2009 I don't get the second part... Would this work: <input type="hidden" name="radio" value="no"/>No<br/> ? Quote Link to comment https://forums.phpfreaks.com/topic/166311-quick-form-help/#findComment-877017 Share on other sites More sharing options...
didgydont Posted July 17, 2009 Share Posted July 17, 2009 <?php $id = how ever you get you id ; echo " <fieldset style='padding: 10px;'> <legend>Delete Account: " . $_SESSION['username'] . "</legend> <form action='daccount.php' method='get'> <input type='radio' name='yes' value='Delete Account'/>Yes<br/> <input type='radio' name='no' value='No'/>No<br/> <input type='hidden' name='id' value='$userid'/> <input type='submit' value='Submit' name='Submit'/> </form> </fieldset> "; include "db.php"; if($_POST['yes']=="Delete Account" ){ mysql_query("DELETE FROM users WHERE id='$_POST[id]' AND username='$_SESSION[username]' "); echo " Hope you enjoyed MythScape. Sorry you un-registered."; echo "<a href=\"index.php\"> Click here </a> to Go Home"; } else{ echo "Not deleted!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/166311-quick-form-help/#findComment-877018 Share on other sites More sharing options...
Cetanu Posted July 17, 2009 Author Share Posted July 17, 2009 Thanks But: It still echoes "Not Deleted" no matter what. And, the account doesn't get deleted. Quote Link to comment https://forums.phpfreaks.com/topic/166311-quick-form-help/#findComment-877024 Share on other sites More sharing options...
didgydont Posted July 17, 2009 Share Posted July 17, 2009 create a test php file to an account you can delete enter vaules in manualy for now obviosly change 1 and johndoe <?php include("db.php"); mysql_query("DELETE FROM users WHERE id='1' AND username='johndoe' "); ?> Quote Link to comment https://forums.phpfreaks.com/topic/166311-quick-form-help/#findComment-877030 Share on other sites More sharing options...
didgydont Posted July 17, 2009 Share Posted July 17, 2009 opp and this <?php $id = how ever you get you id ; echo " <fieldset style='padding: 10px;'> <legend>Delete Account: " . $_SESSION['username'] . "</legend> <form action='daccount.php' method='POST'> <input type='radio' name='yes' value='Delete Account'/>Yes<br/> <input type='radio' name='no' value='No'/>No<br/> <input type='hidden' name='id' value='$userid'/> <input type='submit' value='Submit' name='Submit'/> </form> </fieldset> "; include "db.php"; if($_POST['yes']=="Delete Account" ){ mysql_query("DELETE FROM users WHERE id='$_POST[id]' AND username='$_SESSION[username]' "); echo " Hope you enjoyed MythScape. Sorry you un-registered."; echo "<a href=\"index.php\"> Click here </a> to Go Home"; } else{ echo "Not deleted!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/166311-quick-form-help/#findComment-877049 Share on other sites More sharing options...
Cetanu Posted July 17, 2009 Author Share Posted July 17, 2009 Okay, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/166311-quick-form-help/#findComment-877066 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.