...

View Full Version : PHP Email form



digisoft
09-12-2005, 05:51 PM
Howdy...
Basically i have a form at www.loddonexplorers.co.uk/contact.php ... i know it dosent look good because i worry about cosmetics after it works! I would like a PHP email form basically.. BUT.. i want it to be able to email two address... So when i select Webmaster it emails webmaster@loddonexplorers.co.uk when you click submit, or when you select enquiries it emails enquiries@loddonexplorers.co.uk

Any help would be appreciated! Cheers
Scott

websoftexpert
09-12-2005, 07:19 PM
hi

use following:

if (_Post[Contact] == "webmaster" ) {

$toemail = "webmaster@loddonexplorers.co.uk";

} else {

$toemail = "enquiries@loddonexplorers.co.uk";
}

rest U know. I hope so.

akash sinha
websoftexpert@yahoo.com
http://www.akash.biz

digisoft
09-12-2005, 09:20 PM
Well as i dnt know lol can someone else help me out? Cheers for that tho buddy

bfsog
09-12-2005, 10:55 PM
When you say "select" are we talking radio buttons?

If so, you will have 2 of them like so..



<input type="radio" name="toemail" value="webmaster@loddonexplorers.co.uk" />
<input type="radio" name="toemail" value="enquiries@loddonexplorers.co.uk" />


That way, when the form is submitted, the variable $_POST['toemail'] (assuming your posting and not getting) will either be webmaster@loddonexplorers.co.uk or enquiries@loddonexplorers.co.uk

And your php would be like...



// if user clicks send
if($_POST['submit']=="Send") {
// send the email here, using $toemail to specify where to send.
}


Hope this helps.

JamieR
09-12-2005, 10:57 PM
it's probably full of bugs (haha) but I think I've got the general idea of whatcha after:


<?php

$name = $_POST['name'];
$message = $_POST['message'];
$email = $_POST['email'];

if ($_POST['contact'] == 'webmaster')
{
$email_to = '"Webmaster" <webmaster@londonexplorers.co.uk>';
}else{
$email_to = '"Enquiries" <enquries@londonexplorers.co.uk>';
}

mail($email_to, $name, $message, $email);

exit()
?>


corrected code error :)

digisoft
09-13-2005, 05:35 PM
Lol hi again.. any idea how to fix the error on the website?

http://www.loddonexplorers.co.uk/form_mailer.php

the script is exactly the same as weazels

missing-score
09-13-2005, 06:19 PM
A slight error in weazels code:

change:



$name = $_POST['name'];
$message = $_POST['message;];
$email = $_POST['email'];


to:



$name = $_POST['name'];
$message = $_POST['message'];
$email = $_POST['email'];

JamieR
09-13-2005, 06:22 PM
oops, :o - I wrote that quick ;)

digisoft
09-13-2005, 06:50 PM
lol thanks.. um another error... Parse error on line 2


<?php

$name*=*$_POST['name'];
$message*=*$_POST['message'];
$email*=*$_POST['email'];*

if ($_POST['contact'] == 'webmaster')

$email_to = '"Webmaster" <webmaster@londonexplorers.co.uk>';
}else{
$email_to = '"Enquiries" <enquries@londonexplorers.co.uk>';
}

mail($email_to, $name, $message, $email,);

exit
?>

again avaliable to see at the website mentioned above

missing-score
09-13-2005, 06:52 PM
Sorry, I missed another error in the original code (sorry weazel, but that wasnt your day :p )

change this section here, adding a curly brace below the if($_POST.....) bit.


if ($_POST['contact'] == 'webmaster')
{
$email_to = '"Webmaster" <webmaster@londonexplorers.co.uk>';
}else{
$email_to = '"Enquiries" <enquries@londonexplorers.co.uk>';
}

digisoft
09-13-2005, 07:02 PM
Thanks for the help... still getting the parse error on line 2 (see above)

Fet

missing-score
09-13-2005, 07:19 PM
Well, there are some asterisks *, in there:



$name*=*$_POST['name'];
$message*=*$_POST['message'];
$email*=*$_POST['email'];*


I dont know how they got there though, they shouldnt be in there.

JamieR
09-13-2005, 07:22 PM
ah well....^%$" happens :)

digisoft
09-13-2005, 07:29 PM
the astrix dont appear on my version.. heres my current version..


<?php

$name*=*$_POST['name'];
$message*=*$_POST['message'];
$email*=*$_POST['email'];

if*($_POST['contact']*==*'webmaster')
{
$email_to*=*'"Webmaster" <webmaster@londonexplorers.co.uk>';
}else{
$email_to*=*'"Enquiries" <enquries@londonexplorers.co.uk>';
}

mail($email_to,*$name,*$message,*$email,);

exit()
?>


Still getting a parse error.. if we cant fix this anyone know of another script?

EDIT : OK.. I dont know why they the astrix appear.. they arnt on my clipboard!

JamieR
09-13-2005, 11:12 PM
remove the last , from the mail function -

instead of


mail($email_to, $name, $message, $email,);




mail($email_to, $name, $message, $email);


I don't know why the hell them asterisks are appearing tho.

digisoft
09-14-2005, 06:44 PM
<?php

$name*=*$_POST['name'];
$message*=*$_POST['message'];
$email*=*$_POST['email'];

if*($_POST['contact']*==*'webmaster')
{
$email_to*=*'"Webmaster" <webmaster@londonexplorers.co.uk>';
}else{
$email_to*=*'"Enquiries" <enquries@londonexplorers.co.uk>';
}

mail($email_to,*$name,*$message,*$email);

exit()
?>


Code is above.. www.loddonexplorers.co.uk/form_mailer.php... still getting a parse error.. ignore the stars they should be there, dnt know y they r... if you want the code without the stars just let me know

Rich Pedley
09-15-2005, 07:53 PM
might be an idea to check the form, that could cause the problem especially if line 2 then relates to a variable that isn't actually being passed...

digisoft
09-15-2005, 08:36 PM
I belive its a problem with the server because weazel tried it on his server and it seemed to work ok

Rich Pedley
09-16-2005, 10:59 PM
another thing I have had problem with before is the format the file is saved in.

I use Textpad for all my coding work, and it has the ability to save files as unix, Mac, or PC. Could that be the problem? especially as there appears to be an * problem... thinking of which... Where the * appear on here, go through and change/delete the character that is there even if it appears to be correct in your code and see if that has any effect.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum