harpwing Posted August 15, 2008 Share Posted August 15, 2008 Hey everyone I'm not familiar with PHP, (primarily HTML), and having a problem with a web based contact form. There is a number of directories that will access this one form and to save time tailoring a form for each seperate page including the seperate email addresses, I thought it would be easier to just use the one contact form, and people click through the starting to page to get there The problem with this of course is getting the email address from the first page, keeping it on the second where they fill out their information, and sending it to the stored email address, as well as another email address that always stays the same. I tried a number of different ways, here a few snippets of the code from each page (please don't laugh if I totally messed up ) First page: the one that stores the email address (contactform.html) <form action="index.php" method="post" name="form"> <input name="contactad" type="checkbox" value="email@storemail.com" checked /> <input type="submit"/> </form> Second page: a clip out from the web form where the user fills in their details (index.php) <form action="feedback.php" method="post" name="form1"> .............. <input type="hidden" name="<?php include'feedback.php'; $contactad = $_REQUEST['contactad'] ; "$contactad" ?>"> <input type="submit" value="Send"/> <input name="Reset" type="reset" class="form" value="Reset" /> And the third page, the php file that sends the mail (feedback.php) <?php include'index.php'; $contactad = $_REQUEST['$contactad'] ; $mailto = '$contactad,static@email.com' ; ...............................etc. etc. ?> Very confusing for me, probably the most simplest thing in the world for most Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/119808-solved-storing-an-email-address-over-3-pages/ Share on other sites More sharing options...
ratcateme Posted August 15, 2008 Share Posted August 15, 2008 have you looked at $_SESSION php.net/session Scott. Quote Link to comment https://forums.phpfreaks.com/topic/119808-solved-storing-an-email-address-over-3-pages/#findComment-617229 Share on other sites More sharing options...
harpwing Posted August 15, 2008 Author Share Posted August 15, 2008 I have, but didn't necessarily understand it very well Quote Link to comment https://forums.phpfreaks.com/topic/119808-solved-storing-an-email-address-over-3-pages/#findComment-617235 Share on other sites More sharing options...
Fadion Posted August 15, 2008 Share Posted August 15, 2008 I have, but didn't necessarily understand it very well Strange, as sessions are no rocket science. Basically u start by initializing the session in every page ure going to use it. Put this on the very top of your script: <?php session_start(); ?> Then u assign and read session variables like normal variables: <?php session_start(); $email = 'me@email.com'; $_SESSION['email'] = $email; //set the email string in the session variable echo $_SESSION['email']; //will print exactly "me@email.com"; ?> Do u understand it now? Quote Link to comment https://forums.phpfreaks.com/topic/119808-solved-storing-an-email-address-over-3-pages/#findComment-617261 Share on other sites More sharing options...
harpwing Posted August 15, 2008 Author Share Posted August 15, 2008 Sort of, I put the code on each page like you said, but it's still not sending the mail to either address Here's the code: contactform.php: <?php session_start(); echo 'Contact Form'; $contactad = 'kipo400@hotmail.com'; $_SESSION['contactad'] = $contactad; ?> <a href="index.php">Here to Contact Form</a> index.php: <?php session_start(); ?> <html> *html code + contact form*</html> and the email script (feedback.php): <?php session_start(); $_SESSION['contactad'] = $contactad; $mailto = '$contactad,static@email.co.uk' ; $subject = "Contact Form -> Email" ; Quote Link to comment https://forums.phpfreaks.com/topic/119808-solved-storing-an-email-address-over-3-pages/#findComment-617268 Share on other sites More sharing options...
harpwing Posted August 15, 2008 Author Share Posted August 15, 2008 Would I have to make another session on the second page for it to carry onto the first? If so, how would I go about transfering the session from the first page into another session to move from the second page to third? ??? Quote Link to comment https://forums.phpfreaks.com/topic/119808-solved-storing-an-email-address-over-3-pages/#findComment-617282 Share on other sites More sharing options...
lonewolf217 Posted August 15, 2008 Share Posted August 15, 2008 i think you have it backwards, in your email script shouldn't it be $contactad = $_SESSION['contactad']; since you assigned the $_SESSION variable in the contact form, you are trying to retrieve it in the email script Quote Link to comment https://forums.phpfreaks.com/topic/119808-solved-storing-an-email-address-over-3-pages/#findComment-617292 Share on other sites More sharing options...
harpwing Posted August 15, 2008 Author Share Posted August 15, 2008 i've tried it round both ways, still not getting any emails :-\ however if i change $mailto = '$contacted,static@email.com' ; to $mailto = 'kipo400@hotmail.com,static@email.com' ; I do get the emails on both addresses. Quote Link to comment https://forums.phpfreaks.com/topic/119808-solved-storing-an-email-address-over-3-pages/#findComment-617301 Share on other sites More sharing options...
lonewolf217 Posted August 15, 2008 Share Posted August 15, 2008 im no expert on this, but what if you try $mailto = $contactad . ',static@email.com' ; Quote Link to comment https://forums.phpfreaks.com/topic/119808-solved-storing-an-email-address-over-3-pages/#findComment-617302 Share on other sites More sharing options...
harpwing Posted August 15, 2008 Author Share Posted August 15, 2008 Bingo! You've made my day, thank you! Quote Link to comment https://forums.phpfreaks.com/topic/119808-solved-storing-an-email-address-over-3-pages/#findComment-617304 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.