iconicCreator Posted January 29, 2009 Share Posted January 29, 2009 I really don't know much about php but trying to learn. Is there a way I can make the first name of user submitting the form appear on the confirmation page when the form is submitted? Like say Thanks mike for bla bla bla. I had this set up on a previous form but that form echo the string when the form was submitted. But with this new form, php is calling a different page vial a URL. Is this possible or is there a better way? The old form look like this. <?php $myVar = "Thanks <span class=\"sendersName\"> $firstName</span> for evaluating our product, we will contact you within 24 hours."; ?> <div class="confirmation"><?php echo $myVar; ?></div> The new form - it goes to a new page that contains a confirmation message. // send it $mailSent = mail($to, $subject, $message, 'From: '.$firstName.' '.$lastName.' <'.$email.'>' ); if ($mailSent) { //redirect the page with a fully qualified URL header('Location: http://www.patrickjudson.com/confirmation.php'); exit; } } Thanks for your time and patience with my ignorance. Quote Link to comment Share on other sites More sharing options...
CroNiX Posted January 29, 2009 Share Posted January 29, 2009 if you change this line: header('Location: http://www.patrickjudson.com/confirmation.php'); to: header('Location: http://www.patrickjudson.com/confirmation.php?fname=' . $firstName); then on your confirmation.php page you could: $fname = isset($_GET['fname']) ? $_GET['fname'] : ''; if(!empty($fname)) { //do your confirmation message } And now you can use $fname on the confirmation.php page Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted January 29, 2009 Share Posted January 29, 2009 If you don't want to pass it through the url (although that's what I'd do - it's simple and it gets the job done with little overhead), you could use sessions. <?php session_start(); // At the very top // send it $mailSent = mail($to, $subject, $message, 'From: '.$firstName.' '.$lastName.' <'.$email.'>' ); if ($mailSent) { //redirect the page with a fully qualified URL $_SESSION['firstName'] = $firstName; header('Location: http://www.patrickjudson.com/confirmation.php'); exit; } } Then on the conformation page... <?php session_start(); // at the top again ?> <div class="confirmation">Thanks <span class=\"sendersName\"> <?php echo isset($_SESSION['firstName']) ? $_SESSION['firstName'] : '' ?></span> for evaluating our product, we will contact you within 24 hours.</div> Although you might want to make sure the session variable is set on that page before trying to echo it. Quote Link to comment Share on other sites More sharing options...
iconicCreator Posted January 29, 2009 Author Share Posted January 29, 2009 If you don't want to pass it through the url (although that's what I'd do - it's simple and it gets the job done with little overhead), you could use sessions. <?php session_start(); // At the very top // send it $mailSent = mail($to, $subject, $message, 'From: '.$firstName.' '.$lastName.' <'.$email.'>' ); if ($mailSent) { //redirect the page with a fully qualified URL $_SESSION['firstName'] = $firstName; header('Location: http://www.patrickjudson.com/confirmation.php'); exit; } } Then on the conformation page... <?php session_start(); // at the top again ?> <div class="confirmation">Thanks <span class=\"sendersName\"> <?php echo isset($_SESSION['firstName']) ? $_SESSION['firstName'] : '' ?></span> for evaluating our product, we will contact you within 24 hours.</div> Although you might want to make sure the session variable is set on that page before trying to echo it. I'm going to give this a shot and will get back to you shortly. Thanks for the help, I really appreciate your efforts. IC Quote Link to comment Share on other sites More sharing options...
iconicCreator Posted January 29, 2009 Author Share Posted January 29, 2009 If you don't want to pass it through the url (although that's what I'd do - it's simple and it gets the job done with little overhead), you could use sessions. <?php session_start(); // At the very top // send it $mailSent = mail($to, $subject, $message, 'From: '.$firstName.' '.$lastName.' <'.$email.'>' ); if ($mailSent) { //redirect the page with a fully qualified URL $_SESSION['firstName'] = $firstName; header('Location: http://www.patrickjudson.com/confirmation.php'); exit; } } Then on the conformation page... <?php session_start(); // at the top again ?> <div class="confirmation">Thanks <span class=\"sendersName\"> <?php echo isset($_SESSION['firstName']) ? $_SESSION['firstName'] : '' ?></span> for evaluating our product, we will contact you within 24 hours.</div> Although you might want to make sure the session variable is set on that page before trying to echo it. Hey, I'm getting the following error message when the confirmation page loads. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /hsphere/local/home/drofya/patrickjudson.com/confirmation.php:6) in /hsphere/local/home/drofya/patrickjudson.com/confirmation.php on line 40 I'm already getting a migraine Any ideas? The page is loading with the name and confirmation message but the error message is on the top. IC Quote Link to comment Share on other sites More sharing options...
trq Posted January 29, 2009 Share Posted January 29, 2009 See here. Quote Link to comment Share on other sites More sharing options...
iconicCreator Posted January 29, 2009 Author Share Posted January 29, 2009 See here. Thanks, problem fixed! So simple, I feel like running in the ice! ;D Thanks very much everyone! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.