Here's my situation: I had someone create a PHP form for me. I have inserted it into a website I am designing. The form works on my personal host (except still trying to figure out how to have the uploaded file be attached to the sent email), but I am getting an error where the form will actually be hosted. See below.
Please let me know if any more info is needed.
Form:
http://www.jjbuttons.com/order
Error on submission:
Warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in /home/content/j/u/m/jumpinjack/html/form/attach_mailer_class.php on line 186
Error while sending you mail.
Host:
GoDaddy
PHP version:
4.4.9
http://www.jjbuttons.com/info.php
Same form / code:
http://www.chrisdoughmandesign.com/order.html
Mail submits (except still trying to figure out how to have uploaded file be attached to email)
Host: JustHost
PHP version:
5.2.16
http://www.chrisdoughmandesign.com/info.php
<?php
if(isset($_POST['cmd']) && ($_POST['cmd'] == 'complete'))
{
if(isset($_POST['completeorder'])) {
//UPDATE THESE VARIABLES
$to = 'user@example.com'; // TODO: Change to your desired email.
$cc = ""; //OPTIONAL
$bcc = ""; //OPTIONAL
$subject = 'Order Form Submission'; //TODO: Update to a subject for the email that you like
$uploadpath = $_SERVER['DOCUMENT_ROOT']."/files/mail/"; //TODO: Change path to match your environment
$max_size = 1024*2; //TODO: Update the max. size for uploading in kbs
require($_SERVER['DOCUMENT_ROOT']."/form/attach_mailer_class.php"); //TODO: Change path to match your environment
include ($_SERVER['DOCUMENT_ROOT']."/form/upload_class.php"); //TODO: Change path to match your environment
//EDITTING BELOW THIS SHOULD NOT BE NECESSARY
$name = $_POST['fname'] . ' ' . $_POST['lname'];
$from = $_POST['email'];
$msg = "";
$body ='
<!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=utf-8" />
<title>Untitled Document</title>
<style>
.rounded_corners
{
border-radius: 15px;
-moz-border-radius: 15px;
}
fieldset
{
margin:10px auto;
}
#commentForm label.error, #commentForm input.submit { margin-left: 10px; }
</style>
</head>
<body>
<div style="margin:0 auto; width:900px; padding:10px;">
<fieldset class="rounded_corners">
<LEGEND ACCESSKEY=I style="font-weight:bold; padding:1px 5px;"> Billing / Shipping Information</LEGEND>
<div style="float:left; width:430px; ">
<div class="rounded_corners" style="background-color:#EEE; padding:5px; font-weight:bold; ">Bill To:</div>
<div>
<table style="margin-left:5px; width:100%:" cellpadding="3" cellspacing="0">
<tr>
<td style="width:110px; text-align:right;">* First Name:</td>
<td style="width:290px;">'.$_POST['fname'].'</td>
</tr>
<tr>
<td style="text-align:right;">* Last Name:</td>
<td>'.$_POST['lname'].'</td>
</tr>
<tr>
<td style="text-align:right;">Company:</td>
<td>'.$_POST['company'].'</td>
</tr>
<tr>
<td style="text-align:right;">Address 1</td>
<td>'.$_POST['add1'].'</td>
</tr>
<tr>
<td style="text-align:right;">Address 2</td>
<td>'.$_POST['add2'].'</td>
</tr>
<tr>
<td style="text-align:right;">City:</td>
<td>'.$_POST['city'].'</td>
</tr>
<tr>
<td style="text-align:right;">State:</td>
<td>'.$_POST['state'].'</td>
</tr>
<tr>
<td style="text-align:right;">* Zip:</td>
<td>'.$_POST['zip'].'</td>
</tr>
<tr>
<td style="text-align:right;">* Phone:</td>
<td>'.$_POST['phone'].'</td>
</tr>
<tr>
<td style="text-align:right;">* Email:</td>
<td>'.$_POST['email'].'</td>
</tr>
</table>
</div>
</div>
<div style="float:right; width:430px;">
<div class="rounded_corners" style="background-color:#EEE; padding:5px; font-weight:bold; ">
<span style="float:left;">Ship To:</span>
<span style="float:right;"><input type="checkbox" name="sameasbilling" id="sameasbilling" /></span>
<div style="clear:both; height:1px;"></div>
</div>
<div>
<table style="margin-left:5px; width:100%:" cellpadding="3" cellspacing="0">
<tr>
<td style="width:110px; text-align:right;">* First Name:</td>
<td style="width:290px;">'.$_POST['fname2'].'</td>
</tr>
<tr>
<td style="text-align:right;">* Last Name:</td>
<td>'.$_POST['lname2'].'</td>
</tr>
<tr>
<td style="text-align:right;">Company:</td>
<td>'.$_POST['company2'].'</td>
</tr>
<tr>
<td style="text-align:right;">Address 1</td>
<td>'.$_POST['add12'].'</td>
</tr>
<tr>
<td style="text-align:right;">Address 2</td>
<td>'.$_POST['add22'].'</td>
</tr>
<tr>
<td style="text-align:right;">City:</td>
<td>'.$_POST['city2'].'</td>
</tr>
<tr>
<td style="text-align:right;">State:</td>
<td>'.$_POST['state2'].'</td>
</tr>
<tr>
<td style="text-align:right;">* Zip:</td>
<td>'.$_POST['zip2'].'</td>
</tr>
<tr>
<td style="text-align:right;">* Phone:</td>
<td>'.$_POST['phone2'].'</td>
</tr>
</table>
</div>
</div>
<div style="clear:both; height:1px;"></div>
<div style="width:100%; text-align:center;"> * indicates required information</div>
</fieldset>
<fieldset class="rounded_corners">
<legend accesskey="2" style="font-weight:bold; padding:1px 5px;"> Order</LEGEND>
<div class="rounded_corners" style="background-color:#EEE; padding:5px; font-weight:bold; ">
<table style="width:100%;">
<tr>
<td style="width: 150px;"></td>
<td style="font-weight:bold; text-align:center;">Button Size</td>
<td style="font-weight:bold; text-align:center;">Quantity</td>
<td style="font-weight:bold; text-align:center;">Button Back</td>
<td style="font-weight:bold; text-align:center;"></td>
</tr>
</table>
</div>
<div style="width:100%; padding:5px;">
<table style="width:100%;" cellpadding="2">
<tr>
<td style="width: 150px; text-align:center; font-weight:bold;">* Product 1</td>
<td style="">'.$_POST['size1'].'</td>
<td style="">'.$_POST['qty1'].'</td>
<td style="">'.$_POST['back1'].'</td>
<td style=""></td>
</tr>';
if(isset($_POST['size2']) && isset($_POST['qty2']) && isset($_POST['back2']))
{
$body .= '<tr>
<td style="width: 150px; text-align:center; font-weight:bold;">Product 2</td>
<td style="">'.$_POST['size2'].'</td>
<td style="">'.$_POST['qty2'].'</td>
<td style="">'.$_POST['back2'].'</td>
<td style=""></td>
</tr>';
}
if(isset($_POST['size3']) && isset($_POST['qty3']) && isset($_POST['back3']))
{
$body .= '<tr>
<td style="width: 150px; text-align:center; font-weight:bold;">Product 3</td>
<td style="width: 150px; text-align:center; font-weight:bold;">Product 2</td>
<td style="">'.$_POST['size3'].'</td>
<td style="">'.$_POST['qty3'].'</td>
<td style="">'.$_POST['back3'].'</td>
<td style=""></td>
</tr>';
}
if(isset($_POST['size4']) && isset($_POST['qty4']) && isset($_POST['back4']))
{
$body .= '<tr>
<td style="width: 150px; text-align:center; font-weight:bold;">Product 4</td>
<td style="width: 150px; text-align:center; font-weight:bold;">Product 2</td>
<td style="">'.$_POST['size4'].'</td>
<td style="">'.$_POST['qty4'].'</td>
<td style="">'.$_POST['back4'].'</td>
<td style=""></td>
</tr>';
}
$body .= '</table>
</div>
</fieldset>
<fieldset class="rounded_corners">
<LEGEND accesskey="3" style="font-weight:bold; padding:1px 5px;">Miscellaneous Info</LEGEND>
<table cellpadding="5">
<tr>
<td style="width:280px; text-align:center;">*When do you need your order?</td>
<td style="width:280px; text-align:center;">'.$_POST['month'].'</td>
<td style="width:280px; text-align:center;">'.$_POST['days'].'</td>
</tr>
<tr>
<td style="width:280px; text-align:center;">Is this a Quote or an Order?</td>
<td style="width:280px; text-align:center;">'.$_POST['saletype'].'</td>
<td style="width:280px; text-align:center;"></td>
</tr>
<tr>
<td style="width:280px; text-align:center;">Have you ordered from us before?</td>
<td style="width:280px; text-align:center;">'.$_POST['prevorder'].'</td>
<td style="width:280px; text-align:center;"></td>
</tr>
<tr>
<td colspan="3" style="width:100%; text-align:center; font-weight:bold;">
Comments, questions, special instructions:
</td>
</tr>
<tr>
<td colspan="3" style="width:100%; text-align:center;">
'.$_POST['comments'].'
</td>
</tr>
</table>
</fieldset>
</div>
</body>
</html>';
$my_mail = new attach_mailer($name , $from , $to, $cc , $bcc, $subject, $body);
if (isset($_FILES)) {
foreach ($_FILES as $key => $file) {
for($i = 0; $i < count($file['name']); $i++)
{
if(isset($file['tmp_name'][$i]) && $file['tmp_name'][$i] != '')
{
$my_upload = new file_upload;
$my_upload->extensions = array(".ai", ".eps", ".pdf", ".psd", ".jpg", ".jpeg");
$my_upload->rename_file = false;
$my_upload->upload_dir = $uploadpath;
$my_upload->the_temp_file = $file['tmp_name'][$i];
$my_upload->the_file = $file['name'][$i];
$my_upload->http_error = $file['error'][$i];
if ($my_upload->upload()) {
$full_path = $my_upload->upload_dir.$my_upload->file_copy;
$my_mail->create_attachment_part($full_path);
$my_upload->del_temp_file($full_path);
}
$msg .= $my_upload->show_error_string();
}
}
}
}
$my_mail->process_mail();
$msg .= $my_mail->get_msg_str();
echo $msg;
}
}
elseif(isset($_POST['cmd']) && $_POST['cmd'] == 'set_opts')
{
switch ($_POST['selected']) {
case '1\" Round':
$options = array('Select Back Button', 'Pin Back','Magnet Back','Zipper Pull');
break;
case '1.25\" Round':
$options = array('Select Back Button', 'Pin Back','Magnet Back','Zipper Pull');
break;
case '2.25\" Round':
$options = array('Select Back Button', 'Pin Back','Magnet Back', 'Bottle Opener', 'Bottle Opener With Key Ring');
break;
case '3\" Round':
$options = array('Select Back Button', 'Pin Back','Magnet Back');
break;
case '3.5\" Round':
$options = array('Select Back Button', 'Pin Back','Magnet Back');
break;
case '2x3\" Rectangle':
$options = array('Select Back Button', 'Pin Back','Magnet Back');
break;
case '3x2\" Vertical Rectangle':
$options = array('Select Back Button', 'Pin Back','Magnet Back');
break;
case '2x2 Square':
$options = array('Select Back Button', 'Pin Back','Magnet Back');
break;
case '2x2 Diamond':
$options = array('Select Back Button', 'Pin Back','Magnet Back');
break;
case 'Select Button Size':
$options = array('Select Back Button');
break;
}
echo json_encode(array('result' => $options));
}
?>