0

First, I send the id to rec_update.php file like this:

location.href="http://localhost/pk/rec_update.php?id="+id;

On rec_update.php file, I access that value like this:

$id = $_GET['id'];

Now, I want to send this $id to rec_update1.php file. which can be called by clicking a button. On button I have applied a javascript function from where page will directs to rec_update1.php How do I get this value on another php file.

Kapil Garg
  • 173
  • 1
  • 2
  • 8

2 Answers2

1

HTML / HTTP is stateless, in other words, what you did / saw on the previous page, is completely disconnected with the current page. Except if you use something like sessions, cookies or GET / POST variables. Sessions and cookies are quite easy to use, with session being by far more secure than cookies. More secure, but not completely secure

.

Session:

<?php
//On page 1
$_SESSION['varname'] = $var_value;

//On page 2
$var_value = $_SESSION['varname'];
?>

Remember to run the session_start() statement on both these pages before you try to access the $_SESSION array, and also before any output is sent to the browser.

Samir Sheikh
  • 2,283
  • 2
  • 19
  • 37
1

In rec_update.php

<script>
    location.href="http://localhost/pk/rec_update1.php?id=<?php echo $id; ?>";
</script>

And in rec_update1.php

$id = $_GET['id'];
Adersh
  • 598
  • 1
  • 9
  • 22