Pass value to next page

I have a php page (search.php) that has a link to another php page. (Reserve.php). I want to

  1. pass the link text to the next page
  2. display that link text in a input box

      

Please tell me how can I write the correct coding for the above tasks.

search.php

<a href="Reserve.php"><?php echo $row['AccNo'];?></a>

      

+3


source to share


3 answers


Your Search.php has

<a href="Reserve.php?AccNo=<?php echo $row['AccNo']; ?>">Go to Reserve Page</a>

Now at Reserve.php Get this AccNo with GET

$AccNo=$_GET['AccNo'];



and then just highlight the $AccNo

Variable in the text input field

<input type="text" value="<?php echo $AccNo; ?>" >

Hope it helps

0


source


You can use _GET

to accomplish this:

<a href="Reserve.php?accno=<?php echo $row['AccNo']?>"><?php echo $row['AccNo'];?></a>

      



On a new page, the value of the variable is in the variable $_GET['accno']

. To display this text in the input field, simply use echo $_GET['accno']

.

Note that the text will appear in the url and therefore can be easily modified. Depending on the purpose you are using this for, you can introduce additional checks, etc. On a new page.

+3


source


You can use $_SESSION

to pass values ​​across pages.

$_SESSION['AccNo'] = $row['AccNo']

      

Then you can access it via $_SESSION['AccNo']

on another page. Be careful, make sure you start the session using session_start()

before session using.

If you'd rather use something else, @ Max's answer was also a good way to get data from one page to another, but I would not recommend it for sensitive information.

0


source







All Articles