I'm trying to make a form whose fields will be automatically populated from the url. Also, if user clicks on "Save me a seat" it should redirect to one location, send email and save cookies. If user clicks on "Not interested, thank you", it should redirect him/her to another location, send email and save cookies.
Now, I haven't worked with PHP for 2 years now and there is much that I forgot.
Here is the code:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if(isset($_POST['submit'])){
// Fetching variables of the form which travels in URL
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$title = $_POST['positiontitle'];
$company = $_POST['companyname'];
$all = array($firstname, $lastname, $title, $company);
if($firstname !=''&& $lastname !=''&& $title !=''&& $company !='')
{
// To redirect form on a particular page
header("Location:http://www.example.com");
}
else{
?><span><?php echo "Please fill in all fields!";?></span> <?php
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="noindex, nofollow" />
</head>
<body>
<form class="conf-form" method="POST">
<legend>Please input your information:</legend><br />
First name:<br>
<input class="fst-name" type="text" name="firstname" value="First Name">
<br><br />
Last name:<br>
<input class="lst-name" type="text" name="lastname" value="Last Name">
<br /><br />
Position title:<br />
<input class"pos-title" type="text" name="positiontitle" value="Position Title"/>
<br /> <br />
Company name:<br />
<input class="cmp-name" type="text" name="companyname" value="Company Name"/>
<br /><br />
<input id="save-me" type="submit" value="Save me a seat" name="submit"> <input id="not-int" type="submit" value="Not interested, thank you" name="notsubmit">
<br /><br />
If you have any comments/questions please let us know here:<br />
<textarea rows="4" cols="50"></textarea>
</form>
</body>
</html>
It's not redirecting where I want it. For start, how do I fix this?