Page 1 of 1

Help with simple form

Posted: Sat Jun 21, 2008 9:07 pm
by sparkiii
Hi, I have a simple verification form at

http://zandella.com/contact.php

it goes through mailer.php and I have played around with the code as follows

Code: Select all

<?php
// ----------------------------------------- 
//  The Web Help .com
// ----------------------------------------- 
// remember to replace you@email.com with your own email address lower in this code.
 
// load the variables form address bar
$subject = $_REQUEST["subject"];
$country = $_REQUEST["country"];
$name = $_REQUEST["name"];
$message = $_REQUEST["message"];
$from = $_REQUEST["from"];
$verif_box = $_REQUEST["verif_box"];
 
// remove the backslashes that normally appears when entering " or '
$name = stripslashes($name); 
$country = stripslashes($country); 
$message = stripslashes($message); 
$subject = stripslashes($subject); 
$from = stripslashes($from); 
 
// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
    // if verification code was correct send the message and show this page
[color=#FF0000] mail("my_email@exemail.com.au", 'Online Form Enquiry from '.$name,"\n\n".$message,"\n\n".$country, "From: $from");[/color] // delete the cookie so it cannot sent again by refreshing this page
    setcookie('tntcon','');
} else {
    // if verification code was incorrect then return to contact page and show error
    header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&name=$name&country=$country&how=$how&wrong_code=true");
    exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>E-Mail Sent</title>
<style type="text/css">
<!--
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}
-->
</style></head>
 
<body>
Email sent. Thank you.<br />
<br />
Return to <a href="/">home page</a> ? 
</body>
</html>
 
1. My major problem is in red above, as soon as I add other fields, it stops sending from the email address I enter on the form and seems to grab the hosts server address.

2. The other thing is how do I get the drop down box to register and come through with this form. I dont know much about PHP but can usually manipulate code a bit to work for me.

Thanks in Advance.

Nat

Re: Help with simple form

Posted: Sun Jun 22, 2008 5:11 am
by vargadanis
You can use the $_POST['how'] to see what the user checked in the dropdown list. Or if you used get as the method for the form, than use $_GET['how']...

Re: Help with simple form

Posted: Sun Jun 22, 2008 7:15 pm
by sparkiii
Thankyou, now my line looks like this

Code: Select all

    mail("nat.elmer@exemail.com.au", 'Online Form Enquiry from '.$name,"\n\n".$message,"\n\n".$country, .$_POST['how'] "From: $from");
 
it then warned that there was an unexpected'.' so i removed it

but keep getting the error

Warning: mail() expects at most 5 parameters, 6 given in D:\inetpub\vhosts\zandella.com\httpdocs\mailer.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at D:\inetpub\vhosts\zandella.com\httpdocs\mailer.php:25) in D:\inetpub\vhosts\zandella.com\httpdocs\mailer.php on line 27

:banghead:

Re: Help with simple form

Posted: Sun Jul 13, 2008 8:11 am
by vargadanis
It's been long since sb posted here but I don't like unanswered posts...

Code: Select all

mail("nat.elmer@exemail.com.au", 'Online Form Enquiry from ', $name.'\n\n'.$message.'\n\n'.$country.$_POST['how'], "From:". $from);
The syntax should be fine now.