UnrEALMe Posted May 17, 2007 Share Posted May 17, 2007 hi everyone.. can php create a link ?? i need to pass a value from a .php to another .php.... if using html is like that... <p><a href="main.php">Main</a> </p> how to use php to do so ?? or html can do it ?? i need to pass a value from a form to the other form.. please advice Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/ Share on other sites More sharing options...
taith Posted May 17, 2007 Share Posted May 17, 2007 4 ways of passing infromation from one page to another... post, get, session, cookie... easiest way, is get... <p><a href="main.php?variable=string">Main</a></p> then on your next page... $var=$_GET[variable]; Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-255213 Share on other sites More sharing options...
MadTechie Posted May 17, 2007 Share Posted May 17, 2007 Using post is common in forms.. heres an example (this also emails you the data passed) Form to mail Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-255215 Share on other sites More sharing options...
UnrEALMe Posted May 17, 2007 Author Share Posted May 17, 2007 if i wan to pass a value is store inside $username?? how ??? Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-255398 Share on other sites More sharing options...
AbydosGater Posted May 17, 2007 Share Posted May 17, 2007 You have it stored in $username.. So you use: //file one to send data <?php $username = "Andy"; echo '<a href=myfile.php?username='.$username.'>Click Here</a>'; ?> //File to retrieve data <?php $username = $_GET['username']; echo $username; ?> [code] This is a simple way of doing it. There are many other more secure methods of doing this but by what i can tell your only new to php so this would be a basic way of doing so. Hope it helps. Andy [/code] Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-255408 Share on other sites More sharing options...
UnrEALMe Posted May 17, 2007 Author Share Posted May 17, 2007 hmm the code hlep me alot .. thanks... and if i am using header to redirect.. how ?? header('Location: personaldetails.php'); pls advice... Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-255925 Share on other sites More sharing options...
per1os Posted May 17, 2007 Share Posted May 17, 2007 header('Location: personaldetails.php?username=theusernamehere&extra=extradatahere'); Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-255927 Share on other sites More sharing options...
UnrEALMe Posted May 17, 2007 Author Share Posted May 17, 2007 izzit like this ?? header('Location: tenaga.php?Usernamepass =.$Usernamepass'); Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-255943 Share on other sites More sharing options...
AndyB Posted May 18, 2007 Share Posted May 18, 2007 izzit like this ?? header('Location: tenaga.php?Usernamepass =.$Usernamepass'); What happens when you try it yourself? Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-256030 Share on other sites More sharing options...
AbydosGater Posted May 18, 2007 Share Posted May 18, 2007 Using Headers half way down a file only causes warnings. You could try the following: <?php $username = "Andy"; echo 'Redirecting you now.. Please wait.'; echo '<META HTTP-EQUIV="refresh" CONTENT="5; URL=members.php?username=" . $username . ">"; Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-256124 Share on other sites More sharing options...
chigley Posted May 18, 2007 Share Posted May 18, 2007 If you don't want users to see the variable being sent, you can use sessions to do it without the user knowing Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-256331 Share on other sites More sharing options...
AbydosGater Posted May 18, 2007 Share Posted May 18, 2007 Yes this is how most sites do it. That or cookies but for a new php user they can be tricky Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-256447 Share on other sites More sharing options...
UnrEALMe Posted May 19, 2007 Author Share Posted May 19, 2007 thanks ppl~ Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-256779 Share on other sites More sharing options...
AbydosGater Posted May 19, 2007 Share Posted May 19, 2007 No problem. Glad to help. Andy Quote Link to comment https://forums.phpfreaks.com/topic/51782-solved-how-to-create-link-in-php-pass-value-from-php-to-php/#findComment-256961 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.