As I understand it, you want your script to collect user's name and email, create a URL and redirect the user.
So the script should look something like this (this is just a guide line).
<?php
if(isset($_POST['submit'])){
$name = $_POST["name"];
$email = $_POST["email"];
//create the URL
$url = "http://www.example.com/yourpage.php?name=" . urlencode($name) . "&email=" . urlencode($email);
//send the header
header("Location: " . $url);
//exit the script
exit();
}
?>
<html>
<body>
<form method="post" action="" name="name">
Name:<input type="text" name="name">
Email:<input type="text" name="name">
<input type="submit">
</form>
</body>
</html>
As far as the URL goes, the ?
denotes where your "variables" start.
You should never create a URL from raw user data, especially if you are sending them to one of your other scripts. You should always use urlencode($data)
, this will make the data URL safe. You should also look into data validation and scrubbing.
So what this script does is first check to see if anything has been posted to it, and if so, if collects the data, creates the URL, sends the header for redirection, and exits. If not, it presents a form for the user to enter their info.