/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] 2 PHP Warnings when hitting submit button

Hello All,

I’m attempting submit an HTML form using PHP and I’m getting these 2 errors – not sure what is wrong. ?

Warning: implode() expects at most 2 parameters, 6 given in C:xampphtdocstransferformsend.php on line 67

Warning: mail() expects at least 3 parameters, 1 given in C:xampphtdocstransferformsend.php on line 67
Thank you, your request has been sent!

My PHP code:

<?php
sleep(2);
//Sanitize incoming data and store in variable

$stockNumber = trim(stripslashes(htmlspecialchars ($_POST[‘stockNumber’])));
$serialNumber = trim(stripslashes(htmlspecialchars ($_
POST[‘serialNumber’])));
$description = trim(stripslashes(htmlspecialchars ($_POST[‘description’])));
$requestedBy = trim(stripslashes(htmlspecialchars ($_
POST[‘requestedBy’])));
$requestedDate = trim(stripslashes(htmlspecialchars ($_POST[‘requestedDate’])));
$customerInfo = trim(stripslashes(htmlspecialchars ($_
POST[‘customerInfo’])));

// Array for the R_emails option from form
$R_emails = array(
‘R_boston’ => ‘[email protected]‘,
‘R_columbia’ => ‘[email protected]‘,
‘R_raleigh’ => ‘[email protected]‘,
‘R_orlando’ => ‘[email protected]‘,
‘R_topeko’ => ‘[email protected]‘,
‘R_toledo’ => ‘[email protected]‘,
‘R_cinncinatti’ => ‘[email protected]‘,
‘R_dallas’ => ‘[email protected]‘,
‘R_buffalo’ => ‘[email protected]‘,
‘R_kansas’ => ‘[email protected]‘,
‘R_fairfax’ => ‘[email protected]‘,
‘R_la’ => ‘[email protected]‘,
);

// get receiving email and turn in the the R_email variable
$R_email = $R_emails[ $_POST[‘R_branch’] ];

// Array for the S_emails option from form
$S_emails = array(
‘S_boston’ => ‘[email protected]‘,
‘S_columbia’ => ‘[email protected]‘,
‘S_raleigh’ => ‘[email protected]‘,
‘S_orlando’ => ‘[email protected]‘,
‘S_topeko’ => ‘[email protected]‘,
‘S_toledo’ => ‘[email protected]‘,
‘S_cinncinatti’ => ‘[email protected]‘,
‘S_dallas’ => ‘[email protected]‘,
‘S_buffalo’ => ‘[email protected]‘,
‘S_kansas’ => ‘[email protected]‘,
‘S_fairfax’ => ‘[email protected]‘,
‘S_la’ => ‘[email protected]‘,
);

// get receiving email and turn in the the S_email variable
$S_email = $S_emails[ $_POST[‘S_branch’] ];

//Prepare information from form to be sent
$to = ‘[email protected]‘;
$from = ‘[email protected]‘;
$headers = ‘MIME-VERSION: 1.0’ . ‘n’;
$headers .= ‘From: $from’ . ‘n’;
$subject = ‘Online Order Request’;
$body = ‘Stock Number: ‘ .$stockNumber . PHP_EOL;
$body .= ‘Serial Number: ‘ .$serialNumber . PHP_EOL;
$body .= ‘Description: ‘ .$description . PHP_EOL;
$body .= ‘Requested By: ‘ .$requestedBy . PHP_EOL;
$body .= ‘Requested Date: ‘ .$requestedDate . PHP_EOL;
$body .= ‘Customer Info: ‘ .$customerInfo . PHP_EOL;

// Form data was successful so we will now send admin email and return message to the user
$success = mail( implode(‘,’, array( $R_email, $S_email ), $subject, $body, $headers , ‘-f [email][email protected][/email]‘) );
echo ‘Thank you, your request has been sent!’;

?>

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@heysepJun 27.2013 — $success = mail( implode(',', array( $R_email, $S_email )), $subject, $body, $headers , '-f [email][email protected][/email]');
Copy linkTweet thisAlerts:
@DoubleBitJun 27.2013 — The problem is here:

[code=php]
$success = mail( implode(',', array( $R_email, $S_email ), $subject, $body, $headers , '-f [email protected]') );
[/code]


You should replace it with this:
[code=php]
$success = mail( implode(',', array( $R_email, $S_email )), $subject, $body, $headers , '-f [email protected]' );
[/code]


Note the fact that I've closed the implode bracket after the array bracket. This should do it just fine.
Copy linkTweet thisAlerts:
@sparkymom7authorJun 27.2013 — The problem is here:

[code=php]
$success = mail( implode(',', array( $R_email, $S_email ), $subject, $body, $headers , '-f [email protected]') );
[/code]


You should replace it with this:
[code=php]
$success = mail( implode(',', array( $R_email, $S_email )), $subject, $body, $headers , '-f [email protected]' );
[/code]


Note the fact that I've closed the implode bracket after the array bracket. This should do it just fine.[/QUOTE]


My error message is gone, I received msg. "Thank you, your request has been sent!"

BUT I did not receive my email - Arrrggghhh.....
Copy linkTweet thisAlerts:
@sparkymom7authorJun 28.2013 — My error message is gone, I received msg. "Thank you, your request has been sent!"

BUT I did not receive my email - Arrrggghhh.....[/QUOTE]


Anyone have a way to test server to see why email didn't send? Is there specific line of code that can be added to my PHP code for testing against server? If so, is it at beginning of PHP code after

<?php

??blah, blah, blah??

Thanks
Copy linkTweet thisAlerts:
@sparkymom7authorJul 08.2013 — Update, I had problems with getting SMTP to work properly while making changes to php.ini and sendmail.ini so I setup PHPMailer and used the following code. I hope this helps someone else down the road.

Now I just have to get server side validation working.

[code=php]
<?php
sleep(2);
require('../PHPMailer/class.phpmailer.php');


$mail = new PHPMailer();


$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "ip address"; // SMTP server


//Sanitize incoming data and store in variable

$stockNumber = trim(stripslashes(htmlspecialchars ($_POST['stockNumber'])));
$serialNumber = trim(stripslashes(htmlspecialchars ($_POST['serialNumber'])));
$description = trim(stripslashes(htmlspecialchars ($_POST['description'])));
$requestedBy = trim(stripslashes(htmlspecialchars ($_POST['requestedBy'])));
$requestedDate = trim(stripslashes(htmlspecialchars ($_POST['requestedDate'])));
$customerInfo = trim(stripslashes(htmlspecialchars ($_POST['customerInfo'])));
$R_branch = trim(stripslashes(htmlspecialchars ($_POST['R_branch'])));
$S_branch = trim(stripslashes(htmlspecialchars ($_POST['S_branch'])));

$R_branch = ucfirst(substr($R_branch, 2)); // removes the R_ and capitalizes first letter of branch in final output to email
$S_branch = ucfirst(substr($S_branch, 2)); // removes the S_ and capitalizes first letter of branch in final output to email



// Array for the R_emails option from form
$R_emails = array(
'R_boston' => '[email protected]',
'R_buffalo' => '[email protected]',
'R_cinncinatti' => '[email protected]',
'R_columbia' => '[email protected]',
'R_dallas' => '[email protected]',

'R_fairfax' => '[email protected]',
'R_kansas' => '[email protected]',
'R_la' => '[email protected]',
'R_orlando' => '[email protected]',
'R_raleigh' => '[email protected]',
'R_toledo' => '[email protected]',
'R_topeka' => '[email protected]',
);


// get receiving email and turn in the the R_email variable
$R_email = $R_email[ $_POST['R_branch'] ];


// Array for the S_emails option from form
$S_emails = array(
'S_boston' => '[email protected]',
'S_buffalo' => '[email protected]',
'S_cinncinatti' => '[email protected]',
'S_columbia' => '[email protected]',
'S_dallas' => '[email protected]',

'S_fairfax' => '[email protected]',
'S_kansas' => '[email protected]',
'S_la' => '[email protected]',
'S_orlando' => '[email protected]',
'S_raleigh' => '[email protected]',
'S_toledo' => '[email protected]',
'S_topeka' => '[email protected]',

);


// get receiving email and turn in the the S_email variable
$S_email = $S_emails[ $_POST['S_branch'] ];

//Prepare information from form to be sent
$body = 'Stock Number: ' .$stockNumber . PHP_EOL;
$body .= 'Serial Number: ' .$serialNumber . PHP_EOL;
$body .= 'Description: ' .$description . PHP_EOL;
$body .= 'Requested By: ' .$requestedBy . PHP_EOL;
$body .= 'Requested Date: ' .$requestedDate . PHP_EOL;
$body .= 'Customer Info: ' .$customerInfo . PHP_EOL;
$body .= 'Requesting Branch: ' .$R_branch . PHP_EOL;
$body .= 'Shipping Branch: ' .$S_branch . PHP_EOL;

// Form data was successful so we will now send admin email and return message to the user
$mail = new PHPMailer();

$mail->IsSMTP();
$mail->Host = "ip address";


$mail->From = "[email protected]";
$mail->FromName = "Excited";
$mail->AddAddress($R_email, 'R_branch');

$mail->AddAddress($S_email, 'S_branch');

$mail->AddCC("[email protected]");

$mail->Subject = "Order Request Form";
$mail->Body = $body;
$mail->WordWrap = 50;

if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Thank you, your request has been sent!';
}
}
?>
[/PHP}
×

Success!

Help @sparkymom7 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...