Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

80 users online



Stupid Delete Function

Stupid Delete Function

Currently viewing this thread: 1 (0 members and 1 guests)


Spookster187

Spookster187

Insomniac
Status: Offline!

Stupid Delete Function

Ok, I have a type of backend. There is a "Sign Up" form on the main page, after it is submitted, the info gets processed and sent into a row. The rows are displayed on the admin page. In the admin page, there is a "Delete user" function. In which you delete a user by the website title (WebName in the table). So, here is the tad PHP scrip that processes the navigation:

PHP:

<?php

if ($deluser) {
$Host 'localhost';
$User 'CENSORED';
$Pass 'CENSORED';
$DBName 'CENSORED';
$Table 'NewUsers';

$Connect mysql_connect ($Host$User$Pass);
mysql_select_db($DBName);

$Delete "DELETE from $Table WHERE WebName = $DeleteName";
$Result mysql_query($Delete);
echo (
'<font>User Deleted, Please Refresh</font>');

mysql_close ($Connect);

} else {

if (
$_GET['id'] == 'delete') {
  echo (
'<br />
 <form method="post">
 <font><b>Enter Website Name:</b></font> <input type="text" name="DeleteName" /> <input type="submit" name="deluser" value="Delete" />
 </form>
  '
);
} elseif (
$_GET['id'] == 'howto') {
  echo (
'<font>
  <b>The URL:</b> http://blizter.net/Website Name/ <i>(NO SPACES)</i>
  </font>'
);
} elseif (
$_GET['id'] == 'usedn') {
  echo (
'<font>
  Blizter
  </font>'
);
} else {
  echo (
'<font><b>No Action Selected</b></font>');
}
}

?>

Ok, basically, the elseif's and the else do not matter at this point. The top form, and the thing to process it is. I have tried so many combinations, but they don't seem to work, some dont process, some do, but dont delete the user.

Anyhelp? Thanks... Smile

___________________

Spoono :: WebDapper :: ValidCode

Motorspin

Motorspin

Neverside Newbie
Status: Offline!
PHP:

<?php

$Delete 
"DELETE from $Table WHERE WebName = '" $DeleteName "'";

?>

___________________

Travis Farrell
http://motorspin.com/stuff/images/avasig/m_enterprisesig.gif

Ynhockey

Ynhockey

Neverside Newbie
Status: Offline!

Or better yet,

PHP:

<?php

$Delete 
"DELETE from $Table WHERE WebName = '".$_POST['DeleteName']. "'";
?>

___________________

Learn HTML

Spookster187

Spookster187

Insomniac
Status: Offline!

Thanks guys, both worked, I like hockey's more though, seems more efficient. Smile

___________________

Spoono :: WebDapper :: ValidCode

Ynhockey

Ynhockey

Neverside Newbie
Status: Offline!

Thx Smile I'm not sure it's more efficient though, it's just correct for all configurations. The way you/Motorspin used wouldn't work on servers which have Register Globals disabled (by now that's most of them, and that's a good thing). And in any case, relying on Register Globals isn't a very good idea, it poses a security risk and is more confusing if you use several pre-set arrays in 1 script ($_GET, $_POST, $_SERVER, $_FILES, etc.)

___________________

Learn HTML

Motorspin

Motorspin

Neverside Newbie
Status: Offline!

Yep, YnHockey is right.. its not much more efficient, but it more secure than having register_globals on. On my part you never know, he could of already assigned $DeleteName to $_POST['DeleteName']; Tongue

___________________

Travis Farrell
http://motorspin.com/stuff/images/avasig/m_enterprisesig.gif

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0184 seconds.