Jump to content

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@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  :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 = '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? :)

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" ;

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.  ::)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.