Jump to content

mysql_query("DELETE"); not deleting!


Foser

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/58405-mysql_querydelete-not-deleting/
Share on other sites

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; }}

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].

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].'">

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.