hi all,
i am having a user table in which userid and username are present. i had a delete button also. so wen i click on the delete button that person details only should get delete. so all i had done. I can delete the information using 'userid'. how can i pass that userid value to the next page.
Thank u.

You can give userid on delete button's href.
e.g. <a href="user.php?act=delete&userid=<?=$result?>">delete</a>

You can give userid on delete button's href.
e.g. <a href="user.php?act=delete&userid=<?=$result?>">delete</a>

that is link na i kept button for deleting.

same way buttons onclick event using js.
<input name="Delete" value="Delete" type="button" onclick="window.location.href='user.php?act=delete&userid=<?=$result?>'" />

Member Avatar for diafol

Can I suggest that you include a confirmation paramater that contains a hash so that only official deletes can occur. In addition, how about a javascript confirm popup that sits between the link and the page with the delete script?

<a href="deleteuser.php?id=3&conf=hsyY62j98HH....">Delete user</a>

The conf parameter is built thus:

$user = 3; //but you usually get this from the DB
$username = "Alan Davies"; //you also get this from the DB
$conf = md5("mysalt" . $user . "another salt");

$link = "<a href=\"deleteuser.php?id=$user&amp;conf=$conf\">Delete $username</a>";

Your deleteuser.php then searches and deciphers the conf:

if(isset($_GET['id']) && isset($_GET['conf']) && $_GET['conf'] == md5("mysalt" . $_GET['id'] . "another salt")){
   //success!
}else{
  //fail
}

I haven't included the confirm popup code, but that's easy with onclick.

Member Avatar for rajarajan2017

You designed the page with form r8!

<form name='frmdetails'  action='delete.php' method='post'>
 ........ 
<input type='submit' value='delete' name='deluser'/>
</form>

I hope you are going to pass the value to the next page(delete.php)

Just get the value from there with post

$uid = $_POST['userid'];
echo $uid
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.