/    Sign up×
Community /Pin to ProfileBookmark

How to send a value to another php page?

Page 1:

<?php
$uid=$_GET[‘uid’];
header(“location: …../page2.php”);
die();
?>

how to get value of $uid in page2.php?

Note:

I don’t want to use
…./page2.php?uid=$uid
this is why I redirect page 1 to page 2.
I hope uid is hidden from user on web address box.

Thanks

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@huckepickAug 05.2009 — the only way to hide transmitted vars from the URL is to send them via post instead of get.

[code=html]
<form action="page1.php" method="post">
<input type="text" name="uid"/>
</form>
[/code]


calling the var in php would then work via the post var

[CODE] $uid=$_GET['uid'];[/CODE]

but why dont you want to use the get thing?

if u just use the page1 to redirect it will never be displayed in the browsers address box


cu

huckepick
Copy linkTweet thisAlerts:
@html20009876authorAug 05.2009 — "post" and _GET[]?

boy, before you become a teacher, you should complete your 12 years study first.
Copy linkTweet thisAlerts:
@huckepickAug 05.2009 — I am sorry for mistyping that

i just copied an forgot to change
[CODE]$uid=$_POST['uid'];[/CODE]

i just wanted to help

and consider your reaction on this little mistake as quite unfriendly

cu

huckepick
Copy linkTweet thisAlerts:
@ryanlundAug 05.2009 — Come on guys, what about sessions?

simply start the session using the function session_start() and then set your session like

$_SESSION['uid']=$id;

for example ......page 1:

[code=php]
<?php
$uid=$_GET['uid'];
session_start();
$_SESSION['uid']=$uid;
header("Location: ...../page2.php");
?>
[/code]


Page 2:

[code=php]
<?PHP

session_start();
$uid=$_SESSION['uid'];

?>
[/code]


Obviously, i recommend validating the first GET before using any of this, and also validate all session values before using them, never know what your user might of done to them.

Ryan
Copy linkTweet thisAlerts:
@huckepickAug 05.2009 — i just focused on the transmitting part of the problem and forgot about handling the data at all

definitely as session would be the way to store $uid before redirecting.

cu

huckepick
Copy linkTweet thisAlerts:
@ryanlundAug 05.2009 — Yeah definatly, i just thought i would drop the validation stuff in there just incase you had just started out at PHP, or even programming for that matter. As long as you have it all in control =)

Ryan
Copy linkTweet thisAlerts:
@MindzaiAug 05.2009 — "post" and _GET[]?

boy, before you become a teacher, you should complete your 12 years study first.[/QUOTE]


Nice response, remind me to never bother posting anything helpful in one of your threads... It's pretty funny that you don't know enough to answer this for yourself, yet you are happy to mock people who do know more and are trying to help you out.
×

Success!

Help @html20009876 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...