tedbg tedbg - 1 year ago 90
PHP Question

Warning: implode() [function.implode]: Invalid arguments passed in

Hi I already checked all the posts with the same title but none helps me. First of all I'm a complete newbie and trying to make sendmail.php to get the information from short contact form I got a premade script and try to add a checkbox but not sure how to grep and send is the box checked or not and send to email.

This is the script:

$to="admin@email.com";/*Your Email*/

$date=date("l, F jS, Y");
$time=date("h:i A");

$hosting = (implode(',', $_POST['hosting']));

$msg=" Message from contact form sent: $date, hour: $time.\n
Име: $firstName\n
Email: $email\n
Телефон: $phone
Хостинг: ".$hosting."\r\n

if($email=="") {
echo "<div class='alert alert-danger'>
<a class='close' data-dismiss='alert'>×</a>
<strong>Warning!</strong> Fill all boxes.
} else {
echo "<div class='alert alert-success'>
<a class='close' data-dismiss='alert'>×</a>
<strong>Will contact with you.</strong>

And this is the part of the contact form code :

input type="checkbox" name="hosting[]" value="Get Hosting"


Answer Source

I am not sure what you need in the variable hosting or why you define the input tag as an array when there is only one value available. You should use

<input type="checkbox" name="hosting" value="Get Hosting">

in your form and can use this instead of implode

$hosting = isset($_POST['hosting']) ? $_POST['hosting'] : 'No Hosting';

It will write "Get Hosting" if the checkbox is set and "No Hosting" if not.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download