Foser Posted July 4, 2007 Share Posted July 4, 2007 this is my code : if (isset($_POST['delete'])){ echo "Are you sure you want to delete {$_GET['user']}?<br>"; echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\"> <label> <input type=\"submit\" name=\"yes\" id=\"yes\" value=\"Yes\" /> </label> <label> <input type=\"submit\" name=\"no\" id=\"no\" value=\"No\" /> </label> </form>"; if(isset($_POST['yes'])) { mysql_query("DELETE FROM user_info WHERE username = '$_GET[user]'"); echo "You have deleted this user. Click <p><a href=\"index.php\">here</a></p> to go back to the admin CP."; exit; } if(isset($POST['no'])){ header("Location: user.php?user={$_GET['user']}"); exit; }} and when i press the yes button it does not execute it. is there something wrong? that inm maybe missing thanks a lot! Quote Link to comment Share on other sites More sharing options...
jagat21 Posted July 4, 2007 Share Posted July 4, 2007 Hi, try this code : if (isset($_POST['yes']) || isset($_POST['no'])){ echo "Are you sure you want to delete {$_GET['user']}?<br>"; echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\"> <label> <input type=\"submit\" name=\"yes\" id=\"yes\" value=\"Yes\" /> </label> <label> <input type=\"submit\" name=\"no\" id=\"no\" value=\"No\" /> </label> </form>"; if(isset($_POST['yes'])) { mysql_query("DELETE FROM user_info WHERE username = '$_GET[user]'"); echo "You have deleted this user. Click <p><a href=\"index.php\">here</a></p> to go back to the admin CP."; exit; } if(isset($POST['no'])){ header("Location: user.php?user={$_GET['user']}"); exit; }} Quote Link to comment Share on other sites More sharing options...
Foser Posted July 4, 2007 Author Share Posted July 4, 2007 but the thing is. that you need toi press edit before seeing the yes or no option. so the way your doing won't apply to the style im making it. the way i want it, is press delete than says are you sure then yes or no. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 4, 2007 Share Posted July 4, 2007 Change this line: echo '<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'].'?user='.$_GET['user'];?>">'; When the user clicks the"yes" button the rest of the URL is being lost, this will preserve it. Quote Link to comment Share on other sites More sharing options...
Foser Posted July 4, 2007 Author Share Posted July 4, 2007 Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\WAMP\www\Projects\LogiPlan\main\admin\user.php on line 14 now i get this error... on the edited line. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 4, 2007 Share Posted July 4, 2007 I closed the string and you're continuing to echo HTML to the browser. My mistake. Also need to edit the next line: echo "<label> Quote Link to comment Share on other sites More sharing options...
Foser Posted July 4, 2007 Author Share Posted July 4, 2007 now this is my new script: if (isset($_POST['delete'])){ echo "Are you sure you want to delete {$_GET['user']}?<br>"; echo '<form id="form1" name="form1" method="post" action="<?php echo $_SERVER[php_SELF]."?user".$_GET[user]; ?> <label> <input type="submit" name="yes" id="yes" value="Yes" /> </label> <label> <input type="submit" name="no" id="no" value="No" /> </label> </form>'; but for some reason when i get to the page it shows it direcly, eventhugh i did not the delete from $_post[delete] also when i click on either one this shows up: Forbidden You don't have permission to access /Projects/LogiPlan/main/admin/< on this server. also this is the url i get on that forbidden page: http://localhost/Projects/LogiPlan/main/admin/%3C?php%20echo%20$_SERVER[php_SELF]. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 4, 2007 Share Posted July 4, 2007 Looks like you're running the scripts from your PC instead from a web server - I've never done this as all my code gets tested live. If the script is called "deleteuser.php" edit this line: echo '<form id="form1" name="form1" method="post" action="deleteuser.php?user='.$_GET[user].'"> 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.