/    Sign up×
Community /Pin to ProfileBookmark

Help with contact form

okay here’s my error:

Warning: mail() expects at most 5 parameters, 9 given in [url]http://***.iesend_contact.php[/url] on line 31

It works perfectly with 5 or less fields,
but it won’t accept anymore.

This is the first php script I’ve ever coded so I’m clueless on this error.

Little help?

PHP Code:

[code=php]
<?php
// Contact subject
$subject =”$subject”;

// Details
$detail=”$detail”;

// Company
$company=”$company”;

// Address
$address=”$address”;

// Phone
$phone=”$phone”;

// Fax
$fax=”$fax”;

// Website
$website=”$website”;

// Mail of sender
$mail_from=”$customer_mail”;
// From
$header=”from: $name <$mail_from>”;

// Enter your email address
$to =’***@***.ie’;

$send_contact=mail($to,$subject,$detail,$company,$address,$phone,$fax,$website,$header);

// Check, if message sent to your email
// display message “We’ve recived your information”
if($send_contact){
echo “We’ve recived your contact information”;
}
else {
echo “Sorry, and error has occured. Please try again.”;
}
?>
[/code]

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@aussie_girlJul 28.2006 — Very simple get rid of all the extra parameters and then concatenate all the details into one variable using .= you may have to do some tweaking with formatting
[code=php]
// Details
$detail="$detail";

// Company
$detail.= "$company";

// Address
$detail.="$address";

// Phone
$detail.="$phone";

// Fax
$detail.="$fax";

// Website
$detail.="$website";

$send_contact=mail($to,$subject,$detail,$header);

[/code]
Copy linkTweet thisAlerts:
@sameer_net_inJul 28.2006 — here is a sample code u can use
[code=php]
<?
$__ADMIN_EMAIL__ = "[email protected]";
if( isset( $_POST['Submit'] ) ) {
$senderMail = StripSlashesExt( $_POST['sender_mail'], "check" );
$senderName = StripSlashesExt( $_POST['sender_name'], "check" );
$subject = StripSlashesExt( $_POST['subject'], "check" );
$message = StripSlashesExt( $_POST['message'], "check" );

if( IsEmail( $senderMail ) == false ){
$log = "<br>The e-mail address syntax is invalid";
}
if( trim( $senderName == "" ) ){
$log .= "<br>The sender name can not be empty";
}
if( trim( $subject ) == "" ){
$log .= "<br>The message must have a subject line";
}
if( trim( $message ) == "" ){
$log .= "<br>The message can not be empty";
}
if( $log == "" ){
str_replace( "n", "<br>", $message );

$sub = $senderName." have contacted you from http://yourdomaincom";

$body .= "<<<< someone contacted you thru your homepage";
$body .= "<br> Sender Name : ". $senderName;
$body .= "<br> Sender Email : ". $senderMail;
$body .= "<br> Subject : ".$subject;
$body .= "<br> Message : ".$message;
$body .= "<br><<<< This message is generated from http://yourdomain.com >>>>";

$sent = @mail( $__ADMIN_EMAIL__, $sub, $body, "From:".$senderName."<".$senderMail.">nReply-to:".$senderMail. "nContent-Type: text/html; charset=iso-8859-15");
if( $sent ){
$log = "Message Sent Successfully";
}else{
$log = "Your message is not sent due to technical problem, <br>Send your message to $__ADMIN_EMAIL__";
}
}
}
?>
[/code]

i hope you can make the required html for it
Copy linkTweet thisAlerts:
@cyberphrauthorJul 28.2006 — Thanks for the help aussie,

only problem is it all comes up in one line...

I'm using Thunderbird,

don't know about other mail clients or webmail..
Copy linkTweet thisAlerts:
@aussie_girlJul 28.2006 — That's what I meant by tweaking with the format..try putting rn after each line of the $detail variable something like this...for all of them
[code=php]
detail="$detail rn";

// Company
$detail.= "$company rn";

// Address
$detail.="$address";

// Phone
$detail.="$phone";

// Fax
$detail.="$fax";

// Website
$detail.="$website"
[/code]
Copy linkTweet thisAlerts:
@cyberphrauthorJul 28.2006 — Thanks a lot ?

Everything is working except entried in the "details" and "name" fields aren't coming through...
Copy linkTweet thisAlerts:
@aaronbdavisJul 28.2006 — That's what I meant by tweaking with the format..try putting rn after each line of the $detail variable something like this...for all of them
[code=php]
detail="$detail rn";

// Company
$detail.= "$company rn";

// Address
$detail.="$address";

// Phone
$detail.="$phone";

// Fax
$detail.="$fax";

// Website
$detail.="$website"
[/code]
[/QUOTE]

You don't need to set a variable to itself. Also, you only need to put quotes around a variable when you want to embed it in a larger string. By putting a variable inside a string, by itself, you are causing the parser to do more work than it needs to. Also, it is a good idea to reduce the number of instructions. i.e., change the above code to the following, to get the same results.
[code=php]
detail .="rn $company rn $address $phone $fax $website"
[/code]
×

Success!

Help @cyberphr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...