Jump to content

[SOLVED] how to create link in php ?? pass value from .php to .php


UnrEALMe

Recommended Posts

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

 

Link to comment
Share on other sites

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];

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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 . ">";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.