1

How to pass the parameter between pages? Below is the code. How should I code the parameter by id in this code?

  function addRowHandlers() {
  var tbody = $("#employee-click"); 
   tbody. each(function() {
   $(this).on('click', function() { 
  window.location.href = "detail.php";

   })
   })
   }
halfer
  • 19,824
  • 17
  • 99
  • 186
adam
  • 13
  • 5

3 Answers3

1

If you need to pass variables securely, that the end user can't modify, to another page your should use PHP Sessions and store the value in there.

https://secure.php.net/manual/en/reserved.variables.session.php

1

You can set id as follows

window.location.href = "detail?id="+id;

And get in detail.php

var url =new URL (window.location.href);

var id = url.searchParams.get("id");

Or use

$_GET['id']
Hưng hoàng
  • 360
  • 2
  • 5
  • 18
0

You can pass variables to other page by query strings.
As in your code add this

window.location.href = "detail.php?var="+myvariable;

And you can get that from detail.php like this

$_GET['var']
prit.patel
  • 330
  • 3
  • 12