Jump to content
MakeWebGames

mail delete system help please?


Nicholas

Recommended Posts

can someone help me please cant figure it out lol.

staff_logs.php

action function

 

case 'mail_del': mail_del(); break;

 

the function

 

function mail_del()
{
global $db,$ir,$c,$userid,$h;
if($ir['user_level'] > 2)
{
die("404");
}
$q=$db->query("SELECT * FROM mail WHERE mail_id={$_GET['mail_id']}");
if(!$db->num_rows($q))
{
print "Error, either this message does not exist, or it had already been deleted.

[url='staff_logs.php?action=maillogs']Go Back[/url]";
$h->endpage();
exit;
}
$db->query("DELETE FROM mail WHERE mail_id={$_GET['ID']}");
print "Message deleted
[url='staff_logs.php?action=maillogs']Go Back[/url]";
}

 

the link

 

[[url='staff_logs.php?action=mail_del&mail_id={$r[']Delete MSG[/url]]

 

not quite sure if ive got the link correct or not, but the function is getting on my nerves lol, cant figure it out...

 

i get this...

 

Query was SELECT * FROM mail WHERE mail_id=

 

meaning....

 

{$_GET['ID']} is wrong but idk what to change it too... ive tried...

 

{$_GET['ID']}

{$_GET['mail_id']}

 

all i can think of... can someone help please?

Link to comment
Share on other sites

Try checking if "$r['mail_id']" that's right..

i think ive already tried

$q=$db->query("SELECT * FROM mail WHERE mail_id={$r['mail_id']}");

i dont think it worked...

 

Do you define the GET?

Is the link correct?

i did say im not sure if the links correct lol.

Link to comment
Share on other sites

add this to check if you set the get?

if(!$_GET['mail_id'])
{
print "Error: No variable set";
exit;
}

 

If that stops your code, then the problem is that the link is not passing the variable on to the next function. So you would need to be looking at how the link is built in the view function.

Link to comment
Share on other sites

add this to check if you set the get?
if(!$_GET['mail_id'])
{
print "Error: No variable set";
exit;
}

 

If that stops your code, then the problem is that the link is not passing the variable on to the next function. So you would need to be looking at how the link is built in the view function.

omg how did i not think of that... how simple, it works now... thanks mate...

Link to comment
Share on other sites

ugh what can be so hard?

$id = isset($_GET['id']) && is_string($_GET['id']) && preg_match("/^\d+$/ims", $_GET['id']) ? $_GET['id'] : null;

if (is_null($id))
      echo "<p class='error'>This is an invalid id.</p>";
else
{
      $sql = $db->query("SELECT `blah`, `blah`, `blah` FROM `table` WHERE `id` = ". $id); ////so hard?
      # Do you script.. What can be so hard!?
}
Link to comment
Share on other sites

$id = isset($_GET['id']) && is_string($_GET['id']) && preg_match("/^\d+$/ims", $_GET['id']) ? $_GET['id'] : null;

would it not be

 $id = ( isset($_GET['id']) AND ctype_digit($_GET['id']) ) ? $_GET['id'] : 0 ;

and then maybe instead of is_null() use empty()

I don't really see the point in the preg_match but if you care to explain...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...