Page 1 of 1

I am about to give up, please help

Posted: Tue Feb 09, 2010 11:04 am
by wak0
i need to send data from this webform to my email and also if the user wants to send an attachment he has the option of sending one or not, right now the form lets you submit, but if there is no attachment the form does not work, if there is attachment, the attachment arrive but no data.

please help

Code: Select all

<?php
 
 
$from = $_REQUEST['fromname'];
$email=$_REQUEST["fromemail"];
$occasion = $_REQUEST['occasion'];
$age = $_REQUEST['age'];
$flavor = $_REQUEST['flavor'];
$filling = $_REQUEST['filling'];
$people = $_REQUEST['people'];
$day = $_REQUEST['day'];
$month = $_REQUEST['month'];
$delivery = $_REQUEST['delivery'];
$text = $_REQUEST['text'];
$phone=$_REQUEST['phone'];
 
    if(isset($_POST['submit']))
    {
        //The form has been submitted, prep a nice thank you message
        $output = '<h1>Thanks for your file and message!</h1>';
        //Set the form flag to no display (cheap way!)
        $flags = 'style="display:none;"';
 
        //Deal with the email
        $to = 'myemail@gmail.com';
        $subject = 'Cake Order';
        $body = '
Email = $email
Name = $name
Phone = $phone
Occasion = $occasion
Age = $age
Flavor = $flavor
Filling = $filling
People = $people
Month = $month
Day = $day
Delivery = $delivery
Text = $text';
 
        $from = 'Client Submition';
        $message = strip_tags($_POST['message']);
        $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
        $filename = $_FILES['file']['name'];
 
        $boundary =md5(date('r', time())); 
 
        $headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
        $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
 
        $message="This is a multi-part message in MIME format.
 
--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
 
--_2_$boundary
Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
 
$message
 
--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$filename\" 
Content-Transfer-Encoding: base64 
Content-Disposition: attachment 
 
$attachment
--_1_$boundary--";
 
        mail($to, $subject, $message, $body, $headers);
    }
?>
<!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=ISO-8859-1" />
   <SCRIPT LANGUAGE="JavaScript">
 
 
function emailCheck (emailStr) {
 
 
 
var checkTLD=1;
 
 
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
 
 
 
var emailPat=/^(.+)@(.+)$/;
 
 
 
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
 
 
var validChars="\[^\\s" + specialChars + "\]";
 
 
var quotedUser="(\"[^\"]*\")";
 
 
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
 
 
var atom=validChars + '+';
 
 
 
var word="(" + atom + "|" + quotedUser + ")";
 
 
 
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
 
 
 
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
 
 
 
var matchArray=emailStr.match(emailPat);
 
if (matchArray==null) {
 
 
 
alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
 
 
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}
 
 
 
if (user.match(userPat)==null) {
 
 
 
alert("The username doesn't seem to be valid.");
return false;
}
 
 
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
 
 
 
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}
 
 
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}
 
 
 
if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}
 
 
 
if (len<2) {
alert("This address is missing a hostname!");
return false;
}
 
 
return true;
}
 
 
</script><style type="text/css">
<!--
body,td,th {
    color: #666;
}
body {
    background-color: #000000;
}
a:link {
    color: #FFFFFF;
}
a:visited {
    color: #FFFFFF;
}
.style1 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #666666;
}
.style34 {font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
}
.style50 {
    font-size: 14px;
    font-family: Arial, Helvetica, sans-serif;
    color: #999999;
}
.style52 {
    font-size: 18px;
    font-family: Arial, Helvetica, sans-serif;
    color: #999999;
}
.style53 {font-size: 12px; color: #999999; }
-->
</style>
<script type="text/JavaScript">
<!--
 
 
 
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</head>
 
<body>
 
<?php echo $output; ?>
 
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="963" colspan="3"><img src="images/weddings_showers_affordable.jpg" alt="Wedding, Showers, Birthday, Quinces Cakes" width="1000" height="176" border="0" usemap="#Map2" /></td>
  </tr>
  <tr>
    <td colspan="3"><img src="images/birthdays_quince_broward.jpg" alt="Dulces y Tortas para Bautizo, Matrimonio y Cumpleanos" width="1000" height="66" border="0" usemap="#Map" />
        <map name="Map" id="Map3">
          <area shape="rect" coords="49,5,127,32" href="about.html" />
          <area shape="rect" coords="194,3,302,33" href="products.html" />
          <area shape="rect" coords="359,4,461,32" href="services.html" />
          <area shape="rect" coords="528,6,627,31" href="contact.html" />
          <area shape="rect" coords="915,49,927,64" href="index.html" />
          <area shape="rect" coords="933,50,946,63" href="products.html" />
          <area shape="rect" coords="955,48,965,62" href="cakes.html" />
      </map></td>
  </tr>
  <tr>
    <td width="21"><img src="images/bodas_bautizos_cumpleanos.gif" width="21" height="1" /></td>
    <td width="958" valign="top" background="images/wedding_shower_birthday.jpg"><form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" <?php echo $flags;?>>
<table width="917" border="0" align="center" cellpadding="3" cellspacing="0">
  <tr>
    <td width="32" rowspan="13"></a></td>
    </tr>
  <tr>
    <td><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif"> Name:</font></div></td>
    <td><input name="name" type="text" id="name" size="30" /></td>
    <td width="385" rowspan="12" align="center">
 </td>
  </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif"> Email:</font></div></td>
    <td width="323"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
      <input name="email" type="text" id="email" size="30" />
    </font></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Phone:</font></div></td>
    <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
      <input name="phone" type="text" id="phone" size="15" />
    </font></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Occasion:</font></div></td>
    <td><label>
      <select name="occasion" id="occasion">
        <option value="no resonse" selected="selected"></option>
        <option value="Wedding">Wedding</option>
        <option value="Baby Shower">Baby Shower</option>
        <option value="Birthday">Birthday</option>
        <option value="Religious">Religious</option>
        <option value="Get Together">Get Together</option>
      </select>
    </label></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Child's Age:</font></div></td>
    <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
      <input name="age" type="text" id="age" size="5" maxlength="3" />
      if applicable</font></td>
    </tr>
  <tr>
    <td><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Flavor:</font></div></td>
    <td><select name="flavor" id="flavor">
      <option value="no response" selected="selected"></option>
      <option value="Strawberry">Strawberry</option>
      <option value="Vanilla">Vanilla</option>
      <option value="Chocolate">Chocolate</option>
      <option value="Rum">Rum</option>
      <option value="Lemon">Lemon</option>
      <option value="Marble">Marble</option>
    </select></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Filling:</font></div></td>
    <td><select name="filling" id="filling">
      <option value="No Filling">No Filling</option>
      <option value="Strawberry Buttercream">Strawberry Buttercream</option>
      <option value="Vanilla Buttercream">Vanilla Buttercream</option>
      <option value="Chocolate Buttercream">Chocolate Buttercream</option>
      <option value="Dulce de Leche with">Dulce De Leche</option>
      <option value="Pineapple">Pineapple</option>
      <option value="Lemon">Lemon</option>
      <option value="Cream Cheese">Cream Cheese</option>
      <option value="Rum Cake">Rum Cake</option>
      <option value="Allergy Free">Allergy Free</option>
      <option value="no response" selected="selected"></option>
    </select></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">People attending:</font></div></td>
    <td><select name="people" id="people">
      <option value="no response" selected="selected"></option>
      <option value="10-15">10-15</option>
      <option value="15-20">15-20</option>
      <option value="20-25">20-25</option>
      <option value="25-30">25-30</option>
      <option value="30-40">30-40</option>
      <option value="40-50">40-50</option>
      <option value="50-75">50-75</option>
      <option value="75-100">75-100</option>
      <option value="100+">100+</option>
    </select></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Date of event:</font></div></td>
    <td><select name="month" id="month">
      <option value="no response" selected="selected"></option>
      <option value="Jan">Jan</option>
      <option value="Feb">Feb</option>
      <option value="March">March</option>
      <option value="April">April</option>
      <option value="May">May</option>
      <option value="June">June</option>
      <option value="July">July</option>
      <option value="Aug">Aug</option>
      <option value="Sep">Sep</option>
      <option value="Oct">Oct</option>
      <option value="Nov">Nov</option>
      <option value="Dec">Dec</option>
    </select>
        <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
        <input name="day" type="text" id="day" size="5" maxlength="3" />
      </font></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Delivery:</font></div></td>
    <td><select name="delivery" id="delivery">
      <option value="no response" selected="selected"></option>
      <option value="Yes">Yes</option>
      <option value="No">Pick up</option>
    </select>
        <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Miramar, 33027</font></td>
    </tr>
  <tr>
    <td><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Message</font></div></td>
    <td><textarea name="message" id="message" cols="40" rows="4"></textarea></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">File:</font></div>    
    <label for="file"></label></td>
    <td><input type="file" name="file" id="file"></td>
    </tr>
</table>
<p align="center"><input type="submit" name="submit" id="submit" value="Submit"></p>
</form></td>
    <td width="21"><img src="images/bodas_bautizos_cumpleanos.gif" width="21" height="1" /></td>
  </tr>
  <tr>
    <td height="30" colspan="3" valign="bottom"><div align="center" class="style1">Copyright &copy; 2009  of Things and Occasions, Inc. All rights reserved.</div></td>
  </tr>
</table>
<map name="Map" id="Map"><area shape="rect" coords="49,5,127,32" href="about.html" />
<area shape="rect" coords="194,3,302,33" href="products.html" />
<area shape="rect" coords="359,4,461,32" href="services.html" />
<area shape="rect" coords="528,6,627,31" href="contact.html" />
<area shape="rect" coords="915,49,927,64" href="index.html" />
<area shape="rect" coords="933,50,946,63" href="products.html" />
</map>
<map name="Map2" id="Map2"><area shape="rect" coords="20,9,531,165" href="index.html" />
</map>
 
</body>
</html>
 

Re: I am about to give up, please help

Posted: Tue Feb 09, 2010 11:24 am
by a.heresey
Your variables are misnamed, you have "name" in your form but you're looking for "fromname" in the beginning.
Same thing with the email and the text box.

You should check that the $_REQUEST variables are set before assigning them to new variables.

Re: I am about to give up, please help

Posted: Tue Feb 09, 2010 12:24 pm
by wak0
i saw the name thing and the email, silly mistake. what i dont get is how to check the variables. I used to have this script running without the attachment part. it sent the info. but since i added that section and i have play around with it, no data and no attachment. any other pointers? i made the changes and re run the script but nothing, no email at all

Re: I am about to give up, please help

Posted: Tue Feb 09, 2010 12:54 pm
by a.heresey
use isset() to findout whether the variable exists before you use it.

Code: Select all

 
$from = (isset($_REQUEST['fromname']))?$_REQUEST['fromname']:'';
 

Re: I am about to give up, please help

Posted: Tue Feb 09, 2010 1:14 pm
by wak0
sorry i guess i m new at this. this is what i have, if i send it without attachment i get a php error if not, i seems that sends but i dont get any emails

Code: Select all

<?php
 
$from = (isset($_REQUEST['fromname']))?$_REQUEST['fromname']:'';
$occasion = (isset($_REQUEST['occasion']))?$_REQUEST['occasion']:'';
$age = (isset($_REQUEST['age']))?$_REQUEST['age']:'';
$flavor = (isset($_REQUEST['flavor']))?$_REQUEST['flavor']:'';
$filling = (isset($_REQUEST['filling']))?$_REQUEST['filling']:'';
$people = (isset($_REQUEST['people']))?$_REQUEST['people']:'';
$day = (isset($_REQUEST['day']))?$_REQUEST['day']:'';
$month = (isset($_REQUEST['month']))?$_REQUEST['month']:'';
$delivery = (isset($_REQUEST['delivery']))?$_REQUEST['delivery']:'';
$text = (isset($_REQUEST['text']))?$_REQUEST['text']:'';
$phone = (isset($_REQUEST['phone']))?$_REQUEST['phone']:'';
 
    if(isset($_POST['submit']))
    {
        //The form has been submitted, prep a nice thank you message
        $output = '<h1>Thanks for your file and message!</h1>';
        //Set the form flag to no display (cheap way!)
        $flags = 'style="display:none;"';
 
        //Deal with the email
        $to = 'sabonges@gmail.com';
        $subject = 'Cake Order';
        $body = '
Email = $fromemail
Name = $fromname
Phone = $phone
Occasion = $occasion
Age = $age
Flavor = $flavor
Filling = $filling
People = $people
Month = $month
Day = $day
Delivery = $delivery
Text = $text';
 
        $from = 'Client Submition';
        $message = strip_tags($_POST['message']);
        $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
        $filename = $_FILES['file']['name'];
 
        $boundary =md5(date('r', time())); 
 
        $headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
        $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
 
        $message="This is a multi-part message in MIME format.
 
--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
 
--_2_$boundary
Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
 
$message
 
--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$filename\" 
Content-Transfer-Encoding: base64 
Content-Disposition: attachment 
 
$attachment
--_1_$boundary--";
 
        mail($to, $subject, $message, $body, $headers);
    }
?>

Re: I am about to give up, please help

Posted: Tue Feb 09, 2010 2:07 pm
by a.heresey
your mail function looks odd to me
wak0 wrote:

Code: Select all

 
        mail($to, $subject, $message, $body, $headers);
 
it has the $body in the headers spot.
http://php.net/manual/en/function.mail.php

Re: I am about to give up, please help

Posted: Tue Feb 09, 2010 3:04 pm
by wak0
like this?

Code: Select all

<?php
 
$from = (isset($_REQUEST['fromname']))?$_REQUEST['fromname']:'';
$occasion = (isset($_REQUEST['occasion']))?$_REQUEST['occasion']:'';
$age = (isset($_REQUEST['age']))?$_REQUEST['age']:'';
$flavor = (isset($_REQUEST['flavor']))?$_REQUEST['flavor']:'';
$filling = (isset($_REQUEST['filling']))?$_REQUEST['filling']:'';
$people = (isset($_REQUEST['people']))?$_REQUEST['people']:'';
$day = (isset($_REQUEST['day']))?$_REQUEST['day']:'';
$month = (isset($_REQUEST['month']))?$_REQUEST['month']:'';
$delivery = (isset($_REQUEST['delivery']))?$_REQUEST['delivery']:'';
$text = (isset($_REQUEST['text']))?$_REQUEST['text']:'';
$phone = (isset($_REQUEST['phone']))?$_REQUEST['phone']:'';
 
    if(isset($_POST['submit']))
    {
        //The form has been submitted, prep a nice thank you message
        $output = '<h1>Thanks for your file and message!</h1>';
        //Set the form flag to no display (cheap way!)
        $flags = 'style="display:none;"';
 
        //Deal with the email
        $to = 'sabonges@gmail.com';
        $subject = 'Cake Order';
        $body = '
Email = $fromemail
Name = $fromname
Phone = $phone
Occasion = $occasion
Age = $age
Flavor = $flavor
Filling = $filling
People = $people
Month = $month
Day = $day
Delivery = $delivery
Text = $text';
 
        $from = 'Client Submition';
        $message = strip_tags($_POST['message']);
        $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
        $filename = $_FILES['file']['name'];
 
        $boundary =md5(date('r', time())); 
 
        $headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
        $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
 
        $message="This is a multi-part message in MIME format.
 
--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
 
--_2_$boundary
Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
 
$message
 
--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$filename\" 
Content-Transfer-Encoding: base64 
Content-Disposition: attachment 
 
$attachment
--_1_$boundary--";
 
        mail($to, $message, $headers, $body, $attachment);
    }
?>

Re: I am about to give up, please help

Posted: Tue Feb 09, 2010 4:08 pm
by a.heresey
try this

Code: Select all

 
if(mail($to, $subject, $body, $headers)){
        echo "Sent!";
    };
 

Re: I am about to give up, please help

Posted: Wed Feb 10, 2010 8:48 am
by wak0
i know where the if line goes but the echo one

is that all they way down



do i replace this<?php echo $flags;?> with echo "Sent!"; };

or

this <?php echo $output; ?> with with echo "Sent!"; };

sorry man im lost

Re: I am about to give up, please help

Posted: Fri Feb 12, 2010 1:15 pm
by a.heresey
replace line 69 of the code you posted with the code i posted.

Re: I am about to give up, please help

Posted: Fri Feb 12, 2010 1:34 pm
by wak0
i did that, but i get an error on line 424 which is the end of my script, let me post the whole script here

Code: Select all

<?php
 
$from = (isset($_REQUEST['fromname']))?$_REQUEST['fromname']:'';
$occasion = (isset($_REQUEST['occasion']))?$_REQUEST['occasion']:'';
$age = (isset($_REQUEST['age']))?$_REQUEST['age']:'';
$flavor = (isset($_REQUEST['flavor']))?$_REQUEST['flavor']:'';
$filling = (isset($_REQUEST['filling']))?$_REQUEST['filling']:'';
$people = (isset($_REQUEST['people']))?$_REQUEST['people']:'';
$day = (isset($_REQUEST['day']))?$_REQUEST['day']:'';
$month = (isset($_REQUEST['month']))?$_REQUEST['month']:'';
$delivery = (isset($_REQUEST['delivery']))?$_REQUEST['delivery']:'';
$text = (isset($_REQUEST['text']))?$_REQUEST['text']:'';
$phone = (isset($_REQUEST['phone']))?$_REQUEST['phone']:'';
 
    if(isset($_POST['submit']))
    {
        //The form has been submitted, prep a nice thank you message
        $output = '<h1>Thanks for your file and message!</h1>';
        //Set the form flag to no display (cheap way!)
        $flags = 'style="display:none;"';
 
        //Deal with the email
        $to = 'xxxxx@gmail.com';
        $subject = 'Cake Order';
        $body = '
Email = $fromemail
Name = $fromname
Phone = $phone
Occasion = $occasion
Age = $age
Flavor = $flavor
Filling = $filling
People = $people
Month = $month
Day = $day
Delivery = $delivery
Text = $text';
 
        $from = 'Client Submition';
        $message = strip_tags($_POST['message']);
        $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
        $filename = $_FILES['file']['name'];
 
        $boundary =md5(date('r', time())); 
 
        $headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
        $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
 
        $message="This is a multi-part message in MIME format.
 
--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
 
--_2_$boundary
Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
 
$message
 
--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$filename\" 
Content-Transfer-Encoding: base64 
Content-Disposition: attachment 
 
$attachment
--_1_$boundary--";
 
if(mail($to, $subject, $body, $headers)){
echo "Sent!";
};
?>
<!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=ISO-8859-1" />
       <meta name="Robots" content="INDEX,FOLLOW">
    <meta name="Revisit-after" content="31 Days">
<SCRIPT LANGUAGE="JavaScript">
 
 
function emailCheck (emailStr) {
 
 
 
var checkTLD=1;
 
 
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
 
 
 
var emailPat=/^(.+)@(.+)$/;
 
 
 
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
 
 
var validChars="\[^\\s" + specialChars + "\]";
 
 
var quotedUser="(\"[^\"]*\")";
 
 
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
 
 
var atom=validChars + '+';
 
 
 
var word="(" + atom + "|" + quotedUser + ")";
 
 
 
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
 
 
 
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
 
 
 
var matchArray=emailStr.match(emailPat);
 
if (matchArray==null) {
 
 
 
alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
 
 
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}
 
 
 
if (user.match(userPat)==null) {
 
 
 
alert("The username doesn't seem to be valid.");
return false;
}
 
 
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
 
 
 
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}
 
 
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}
 
 
 
if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}
 
 
 
if (len<2) {
alert("This address is missing a hostname!");
return false;
}
 
 
return true;
}
 
 
</script><style type="text/css">
<!--
body,td,th {
    color: #666;
}
body {
    background-color: #000000;
}
a:link {
    color: #FFFFFF;
}
a:visited {
    color: #FFFFFF;
}
.style1 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #666666;
}
.style34 {font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
}
.style50 {
    font-size: 14px;
    font-family: Arial, Helvetica, sans-serif;
    color: #999999;
}
.style52 {
    font-size: 18px;
    font-family: Arial, Helvetica, sans-serif;
    color: #999999;
}
.style53 {font-size: 12px; color: #999999; }
-->
</style>
<script type="text/JavaScript">
<!--
 
 
 
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</head>
 
<body>
 
<?php echo $output; ?>
 
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="963" colspan="3"><img src="images/weddings_showers_affordable.jpg" alt="Wedding, Showers, Birthday, Quinces Cakes" width="1000" height="176" border="0" usemap="#Map2" /></td>
  </tr>
  <tr>
    <td colspan="3"><img src="images/birthdays_quince_broward.jpg" alt="Dulces y Tortas para Bautizo, Matrimonio y Cumpleanos" width="1000" height="66" border="0" usemap="#Map" />
        <map name="Map" id="Map3">
          <area shape="rect" coords="49,5,127,32" href="about.html" />
          <area shape="rect" coords="194,3,302,33" href="products.html" />
          <area shape="rect" coords="359,4,461,32" href="services.html" />
          <area shape="rect" coords="528,6,627,31" href="contact.html" />
          <area shape="rect" coords="915,49,927,64" href="index.html" />
          <area shape="rect" coords="933,50,946,63" href="products.html" />
          <area shape="rect" coords="955,48,965,62" href="cakes.html" />
      </map></td>
  </tr>
  <tr>
    <td width="21"><img src="images/bodas_bautizos_cumpleanos.gif" width="21" height="1" /></td>
    <td width="958" valign="top" background="images/wedding_shower_birthday.jpg"><form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" <?php echo $flags;?>>
<table width="917" border="0" align="center" cellpadding="3" cellspacing="0">
  <tr>
    <td width="32" rowspan="13"></a></td>
    </tr>
  <tr>
    <td><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif"> Name:</font></div></td>
    <td><input name="name" type="text" id="name" size="30" /></td>
    <td width="385" rowspan="12" align="center"></td>
  </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif"> Email:</font></div></td>
    <td width="323"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
      <input name="email" type="text" id="email" size="30" />
    </font></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Phone:</font></div></td>
    <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
      <input name="phone" type="text" id="phone" size="15" />
    </font></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Occasion:</font></div></td>
    <td><label>
      <select name="occasion" id="occasion">
        <option value="no resonse" selected="selected"></option>
        <option value="Wedding">Wedding</option>
        <option value="Baby Shower">Baby Shower</option>
        <option value="Birthday">Birthday</option>
        <option value="Religious">Religious</option>
        <option value="Get Together">Get Together</option>
      </select>
    </label></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Child's Age:</font></div></td>
    <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
      <input name="age" type="text" id="age" size="5" maxlength="3" />
      if applicable</font></td>
    </tr>
  <tr>
    <td><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Flavor:</font></div></td>
    <td><select name="flavor" id="flavor">
      <option value="no response" selected="selected"></option>
      <option value="Strawberry">Strawberry</option>
      <option value="Vanilla">Vanilla</option>
      <option value="Chocolate">Chocolate</option>
      <option value="Rum">Rum</option>
      <option value="Lemon">Lemon</option>
      <option value="Marble">Marble</option>
    </select></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Filling:</font></div></td>
    <td><select name="filling" id="filling">
      <option value="No Filling">No Filling</option>
      <option value="Strawberry Buttercream">Strawberry Buttercream</option>
      <option value="Vanilla Buttercream">Vanilla Buttercream</option>
      <option value="Chocolate Buttercream">Chocolate Buttercream</option>
      <option value="Dulce de Leche with">Dulce De Leche</option>
      <option value="Pineapple">Pineapple</option>
      <option value="Lemon">Lemon</option>
      <option value="Cream Cheese">Cream Cheese</option>
      <option value="Rum Cake">Rum Cake</option>
      <option value="Allergy Free">Allergy Free</option>
      <option value="no response" selected="selected"></option>
    </select></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">People attending:</font></div></td>
    <td><select name="people" id="people">
      <option value="no response" selected="selected"></option>
      <option value="10-15">10-15</option>
      <option value="15-20">15-20</option>
      <option value="20-25">20-25</option>
      <option value="25-30">25-30</option>
      <option value="30-40">30-40</option>
      <option value="40-50">40-50</option>
      <option value="50-75">50-75</option>
      <option value="75-100">75-100</option>
      <option value="100+">100+</option>
    </select></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Date of event:</font></div></td>
    <td><select name="month" id="month">
      <option value="no response" selected="selected"></option>
      <option value="Jan">Jan</option>
      <option value="Feb">Feb</option>
      <option value="March">March</option>
      <option value="April">April</option>
      <option value="May">May</option>
      <option value="June">June</option>
      <option value="July">July</option>
      <option value="Aug">Aug</option>
      <option value="Sep">Sep</option>
      <option value="Oct">Oct</option>
      <option value="Nov">Nov</option>
      <option value="Dec">Dec</option>
    </select>
        <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
        <input name="day" type="text" id="day" size="5" maxlength="3" />
      </font></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Delivery:</font></div></td>
    <td><select name="delivery" id="delivery">
      <option value="no response" selected="selected"></option>
      <option value="Yes">Yes</option>
      <option value="No">Pick up</option>
    </select>
        <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Miramar, 33027</font></td>
    </tr>
  <tr>
    <td><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">Message</font></div></td>
    <td><textarea name="message" id="message" cols="40" rows="4"></textarea></td>
    </tr>
  <tr>
    <td width="153"><div align="right" class="style53"><font face="Verdana, Arial, Helvetica, sans-serif">File:</font></div>    
    <label for="file"></label></td>
    <td><input type="file" name="file" id="file"></td>
    </tr>
</table>
<p align="center"><input type="submit" name="submit" id="submit" value="Submit"></p>
</form></td>
    <td width="21"><img src="images/bodas_bautizos_cumpleanos.gif" width="21" height="1" /></td>
  </tr>
  <tr>
    <td height="30" colspan="3" valign="bottom"><div align="center" class="style1">Copyright &copy; 2009  of Things and Occasions, Inc. All rights reserved.</div></td>
  </tr>
</table>
<map name="Map" id="Map"><area shape="rect" coords="49,5,127,32" href="about.html" />
<area shape="rect" coords="194,3,302,33" href="products.html" />
<area shape="rect" coords="359,4,461,32" href="services.html" />
<area shape="rect" coords="528,6,627,31" href="contact.html" />
<area shape="rect" coords="915,49,927,64" href="index.html" />
<area shape="rect" coords="933,50,946,63" href="products.html" />
</map>
<map name="Map2" id="Map2"><area shape="rect" coords="20,9,531,165" href="index.html" />
</map>
 
</body>
</html>
 

Re: I am about to give up, please help

Posted: Fri Feb 12, 2010 3:24 pm
by a.heresey
there shouldn't be a ; after } , sorry.

Re: I am about to give up, please help

Posted: Fri Feb 12, 2010 3:37 pm
by wak0
still get an error. should i just start again with a brand new script instead of patching this one?

Re: I am about to give up, please help

Posted: Fri Feb 12, 2010 3:47 pm
by a.heresey
If I were you I would chop this script up into several files, it would be easier to find the error. It sounds like you've left open a code block or something somewhere. It's hard to tell with sooo much going on.

One file PHP+HTML for displaying the form, One file with the PHP that does the work, one file with the css, and one file with the javascript.

But that's just how I like to work

Re: I am about to give up, please help

Posted: Fri Feb 12, 2010 3:55 pm
by wak0
sounds like a plan, thanks