Jump to content

if not "array" echo out


Monkuar

Recommended Posts

if (empty($_POST['selected_messages']))
			message($lang_pms['Must select']);

		$idlist = array_values($_POST['selected_messages']);
		$idlist = array_map('intval', $idlist);
		$idlist = implode(',', array_values($idlist));

		// If you're not the owner of the message, you can't delete it.
		$result = $db->query('SELECT DISTINCT sender_id FROM '.$db->prefix.'messages WHERE id IN ('.$idlist.') AND folder="sent" ') or error('Unable to delete the message', __FILE__, __LINE__, $db->error());

 

Okay, as you can see it makes intval for all the $_POST['selected_messages'] , but the problem is, when I use tamper data and just add a form field "selected_messages" it brings up a mysql error and the $idlist is blank..

 

 

so is there a way to make sure that the $_POST['selected_messages'] has to equal 'selected_messages[]' OR show error?

 

people can just tamper data and use selected_messages without the [] and it brings up a mysql error, that's not good, I don't want users seeing my code

 

 

 

edit:

 

WOW

 

if (empty($idlist)){
		message("No Permission");
		}

 

fixed it

 

sorry

 

Link to comment
Share on other sites

You could wrap the whole thing checking if isset and also not a blank value

 

Would be of no use to run the query with empty values

 

if (isset($_POST['selected_messages']) && $_POST['selected_messages'] !=''){

//execute code here only if is good

} else {

echo "No Message";
//die("No message");

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

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.