Jump to content

Coding Help


steviez

Recommended Posts

This is my code so far and it dont work, any ideas?

 

 

<?php
include("connect.php");
include("header.php");

if(($user_id != "") && ($remove_user != ""))

{

$update_user = "DELETE FROM users WHERE id = '$UsErId'";
$update_result = mysql_query($update_user);

$redirect = $SITEURL."logout.php";

header("location:$redirect");	

}
?>

<style type="text/css">
<!--
body {
background-image: url("../images/body_background.gif");
}
-->
</style>





<table align="center" width="780" class="frame">
  <tr>
    <td><table width="100%" class="page_content_frame">
      <tr>
        <td><p>By clicking delete account you understand that this can not be reversedand all your work will be lost</p>
          <p><form name="user" action="#" method="get">
                                                                          <input type="hidden" value="<?php echo $row_top[user_id] ?>" name="user_id">
                                                                          <input type="submit" name="remove_user" value="Delete My Account" class="button">
                                                                        </form></p></td>
      </tr>
    </table></td>
  </tr>
</table>

Link to comment
https://forums.phpfreaks.com/topic/37622-coding-help/#findComment-179987
Share on other sites

Actually.... if your users have acoiunts then I'll assume they log in via sessions. Its safer to use this session data to delete the user.

 

Simply make your delete link point to this script.

 

<?php
  session_start();
  if (isset($_SESSION['userid'])) {
    $sql = "DELETE FROM users WHERE userid = '{$_SESSION['userid']}'";
    if (mysql_query($sql)) {
      $redirect = $SITEURL."logout.php";
      header("location:$redirect");
    } else {
      echo "Delete failed";
    }
  }
?>

 

Of course you'll need to change $_SESSION['userid'] to suite your application, but this should give you the idea.

 

Link to comment
https://forums.phpfreaks.com/topic/37622-coding-help/#findComment-179989
Share on other sites

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.