Jump to content

[SOLVED] Storing an email address over 3 pages?


harpwing

Recommended Posts

Hey everyone  :D

 

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  :P

 

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  ;D)

 

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 protected]" 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,[email protected]' ;

...............................etc. etc.

?>

 

Very confusing for me, probably the most simplest thing in the world for most  :D

 

Thanks!  :)

 

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 = '[email protected]';
$_SESSION['email'] = $email; //set the email string in the session variable
echo $_SESSION['email']; //will print exactly "[email protected]";
?>

 

Do u understand it now? :)

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 = '[email protected]';

$_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,[email protected]' ;

$subject = "Contact Form -> Email" ;

i've tried it round both ways, still not getting any emails  :-\

 

however if i change 

 

$mailto = '$contacted,[email protected]' ;

 

to

 

$mailto = '[email protected],[email protected]' ;

 

I do get the emails on both addresses.  ::)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.