0

i have one variable like this

$groupid=$_GET['groupid'];

and in the same page i have one button like this..

  <td>
      <a href="assigncoursedelete.php?id=<?php echo $row->id;?>" onclick="return confirm('Are you sure you wish to delete this Record?');">
      <div style="background-color:#CD5C5C; width:30px; padding-left:9px; padding-top:3px; height:28px; color:white">
      <em class="fa fa-trash"></em></div>
  </td>

and i want to pass that $groupid variable in the above URL..

I tried but its not passing the variable to the delete page..

Can anyone help me how to do this..

Thanks in advance..

1
  • I'd advise using the POST http method for deletions via HTML. Browsers/robots can prefetch/follow links and it results in disaster. Commented Sep 15, 2017 at 10:21

4 Answers 4

1
<td><a href="assigncoursedelete.php?id=<?php echo $row->id;?>&groupid=<?php echo $groupid; ?>" onclick="return confirm('Are you sure you wish to delete this Record?');"><div style="background-color:#CD5C5C; width:30px; padding-left:9px; padding-top:3px; height:28px; color:white">
                                      <em class="fa fa-trash"></em></div></td>

Will this work for you try it

Sign up to request clarification or add additional context in comments.

Comments

1
assigncoursedelete.php?id=<?php echo $row->id;?>&groupid=<?php echo $groupid; ?>

you must use '&' to pass multiple data in URL

1 Comment

then please accept it as valid answer. Glad to help.
0

You can try this :-

<td>
  <a href="assigncoursedelete.php?id=<?php echo $row->id."&groupid=".$groupid;?>" onclick="return confirm('Are you sure you wish to delete this Record?');">
  <div style="background-color:#CD5C5C; width:30px; padding-left:9px; padding-top:3px; height:28px; color:white">
  <em class="fa fa-trash"></em></div>
</td>

Happy Coding :-)

Comments

0

Use the php http_build_query function. It will take care of possible encoding issues:

<?php
$data = [
    'id' => 47,
    'name' => 'this & that'
];

$url = 'destination.php?=' . http_build_query($data, '', '&amp;');
?>
<a href="<?= $url ?>">Do something</a>

Output:

<a href="destination.php?=id=47&amp;name=this+%26+that">Do something</a>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.