Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 02-15-2006, 05:45 PM   #1 (permalink)
 
Newb Techie

Join Date: Jul 2005

Posts: 24

heidi

Default php is a nightmare!

hi-
i'm trying to help my bro-in-law out with his website. everything has been okay until he asked for mail forms. ahhhh! "mailto" doesn't work anymore:mad:

so i need to learn php, right? his server can handle this... it has to be something i'm doing. i got the code from www.php.net & tweaked it to fit his site, but get this error when i click submit:

Warning: mail() expects at most 5 parameters, 8 given in /home/southern/public_html/sendmail.php on line 10

Warning: Cannot modify header information - headers already sent by (output started at /home/southern/public_html/sendmail.php:10) in /home/southern/public_html/sendmail.php on line 11


5 parameters? 8? huh!? well anyway, this is what i have in my php file:

<?
$pre = $_REQUEST['pre'] ;
$first = $_REQUEST['first'] ;
$last = $_REQUEST['last'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$message = $_REQUEST['message'] ;

mail( "jbuche@westerniplaw.com", "Feedback Form Results",
$pre, $first, $last, $phone, $message, "From: $email" );
header( "Location: http://www.southerncaliforniapatents.com/thankyou.html" );
?>

this is the page i'm working with is here:
http://www.southerncaliforniapatents.com/contact8.html

mail forms should be pretty easy, right? has anyone seen this or know why mine won't send? thanks so, so much:o
heidi is offline  
Old 02-15-2006, 08:09 PM   #2 (permalink)
 
Ultra Techie

Join Date: Jul 2005

Posts: 530

TheHeadFL

Send a message via AIM to TheHeadFL
Default

OK the prototype of mail() is
Code:
bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )
I can see that your problem is that you are using commas to concatenate the information you want in your email.

Try this instead:
Code:
$formatted_msg = $pre . " " . $first . " " . $last . "\nFrom: " . $email 
   . "\n" . $phone . "\n" . $message;
mail("jbuche@westerniplaw.com","Feedback Form Results", $formatted_msg);
That will solve both of your problems.
__________________
Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache)
TheHeadFL is offline  
Old 02-16-2006, 08:26 PM   #3 (permalink)
 
Ultra Techie

Join Date: Feb 2004

Posts: 833

hygor

Default

Here is a simplified version of the way I process my php mail forms (though i have not included any error checking or field handling here ... just the send stuff)


// I set the static features (where its going and its subject

$to = 'emailaddress@theinternet.com';
$subject = 'Mail form query';

//Then I populate the from address and email body from my mail form

$body = "Comment/Query:" . $_POST['CommText'];
$from = "From: " . $_POST['EmailTxt'];

//then i send

mail ($to, $subject, $body, $from);


// and redirect to a confirmation page (where my pages are controlled by variables in the query string)

header("Location: ?hs=9");

//this could easily be "Location: thanks.php" or similar

-----

if you have more than one item you want to include in the message copy i.e. phone number, first name etc...

simply build the $body variable as follows

$body = "Name: " . $_POST['NameTxt'] . " ";
$body = $body . "PhoneNo: " . $_POST['PhoneTxt'] . " ";
$body = $body . "Comment/Query:" . $_POST['CommText'] . " ";

Hope this is of some help to you!
__________________
hygor is offline  
Old 02-19-2006, 03:35 AM   #4 (permalink)
Zanjo's Avatar
 
True Techie

Join Date: Oct 2005

Posts: 192

Zanjo is on a distinguished road

Default

The reason is because you are using 8 variables/strings seperated by commas, php thinks those are parameters for the mail function...
You need to combine the variables into 1 variable and put the string into the mail function.

PHP Code:
$string "$pre, $first, $last, $phone, $message";
mail"jbuche@westerniplaw.com""Feedback Form Results",
$string"From: $email" ); 
Or change the string if i didnt pick up on that one correctly.
__________________
Intel Q6600 2.4Ghz SLACR
eVGA 8800GT 512mb Video Card
4GB DDR2-800Mhz RAM
Thermalright Ultra Extreme 120 with Scythe SFlex Fan
160GB Seagate Barracuda 7200.9
500GB Seagate Barracuda 7200.11
22" Viewsonic Widescreen Monitor
3DMark06 Score: 11402
Zanjo is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On