开发者

How to set and get values from an url

开发者 https://www.devze.com 2022-12-21 23:21 出处:网络
I would like to set values on an url like this: <a href=\'http://$data_url/viewyournote.php?chapter=\'$name_of_chapter\'&note=\'$id_note\'&user=\'$username\'>

I would like to set values on an url like this:

<a href='http://$data_url/viewyournote.php?chapter='$name_of_chapter'&note='$id_note'&user='$username'>

Then be able to grab then from the recieving page.

开发者_如何学JAVARight now all im getting is this when clicked:

http://localhost/readnotes/viewyournote.php?chapter=


I don't how you embed your link in your code, but if it is outside of <?php ?> tags, then you have to do:

<a href="http://<?php echo $data_url ?>/viewyournote.php?chapter=<?php echo $name_of_chapter ?>&note=<?php echo $id_note ?>&user=<?php echo $username?>" >

if it is inside these tags, you can also do:

echo  "<a href='http://$data_url/viewyournote.php?chapter=$name_of_chapter&note=$id_note&user=$username?' >";

You can get these values on the recieveing page with $_GET['variable_name_here'], e.g. $_GET['chapter'].


Use Query string

$val = "yourvalue" ;

$url "http://localhost/readnotes/viewyournote.php?chapter=$val";

Now $val is passed to specified url .

There you could get it by using $_GET['chapter'] , It will give you "yourvalue"


<a href='http://$data_url/viewyournote.php?chapter=<?php echo $name_of_chapter; ?>&note=<?php echo $id_note; ?>&user=<?php echo $username; ?>>


Replace your line with

<?php
echo "<a href='http://$data_url/viewyournote.php?chapter='$name_of_chapter'&note='$id_note' user='$username'>";
 ?>

On the receiving end use

<?php
$name_of_chapter = $_GET['chapter'];
...
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号