I'm very new to PHP.
I have an HTML membership form that when a user clicks the submit button it goes to a PHP page that compiles the fields passed, sends an email and lastly forwards the user to a "Thank you" Confirmation" html page.
I would like to include two of the form fields into the URL string so that I can then call up in the confirmation page to congratulate the name of the person for joining our club.
Two Questions
- How do I concatenate the redirect url to include first name and last name for example: new_member_confirmation.html?firstname=$firstname&lastname=$lastname
- how do I then 'GET' the names in the URL string to display on the confirmation html page. For example "Thank you Bill Smith for becoming a member". I dont have an example of this as I do not know how to call or GET the values from the url string into the HML page
Here is the revised code which does not include every form field variable but gives you the gist of the PHP script.
<?php
// Multiple recipients
$to = 'info@abs.com'; // note the comma
// Form http_post_fields
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$subject = 'New Membership';
$cdateTime = date("l jS \of F Y h:i:s A");
// Message
$message = "
<html>
<head>
<title>New Membership</title>
</head>
<strong>From:</strong> \n $firstname \n $lastname <br>
<strong>Email:</strong> \n $email <br>
<strong>Date/Time Submitted:</strong>\n $cdateTime
</font></p>
<body>
</body>
</html>
";
// To send HTML mail, the Content-type header must be set
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
// Additional headers
$headers[] = 'To: Club Name <info@domain.com>'; // include a comma for more than one recipiant
$headers[] = 'From: Club Name <info@domain.com>';
// Mail it
mail($to, $subject, $message, implode("\r\n", $headers)) or die("Email was not sent!");
// Here is where the user gets sent to the page below. Id like to append the $firstname $lastname variables into the URL string
header('Location: membership_confirmation.html');
// I thought I could create a URL string variable above like this --
// $urString = "Location: membership_confirmation.html?membername=$firstname \n $lastname";
// and then add it to the last portion of the script like this
// header($urString);
// Unfortunately, that doesn't work after I tried testing it.
?>