You are giong about this the wrong way. Don't try to hyperlink a submit button.
There are different ways to pass this variable around depending on your usage.
1. If you want to pass it as a GET request variable using only a hyperlink:
Code: Select all
<a href="2.php?url2=<?php echo $url; ?>">Continue</a>
2. If yo uwant to pass it as a GET request after clicking a button (uses the onclick event to perform a javascript redirect):
Code: Select all
<button onclick="window.location ='2.php?url2=<?php echo $url; ?>';">Continue</a>
3. You can store a hidden value in a form to send it with rest of the form inputs
Code: Select all
<form action="2.php" method="get">
<input type="hidden" name="url2" value="<?php echo $url; ?>" />
<input type="text" name="first_name" /><br />
<input type="text" name="last_name" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
All these methods will result in 2.php having access to $_GET['url2'] as whatever you printed $url as in the first page. (In the 3rd method $_GET['first_name'] and $_GET['second_name'] will also include whatever was typed in the form field)
4. You can use
sessions. Start a session with session_start() at the top of both pages. Then set $_SESSION['url2'] = $url in 1.php, and it will be available as $_SESSION['url2'] in 2.php (assuming the user came from 1.php, because that's where it gets set).