Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

phpmailer and checkboxes



12:09 am on Jan 7, 2009 (gmt 0)

5+ Year Member

Hello all, I have two bugs that I need to get fixed and your help would be greatly appreciated. First off my script works but only if zip files are not added. I fill in the form and set in a file box a zip file, hit submit and the script seems to work but none of the values go through and the zip file does not attach. The second issue is that I have eleven checkboxes with nine of them populating correctly. but when I open the fdf with the pdf two of the check boxes do not show through. All names are the same across all three files. What am I doing wrong? You can check it out at <snip>.


[edited by: eelixduppy at 5:29 am (utc) on Jan. 7, 2009]
[edit reason] no URLs, please [/edit]


5:30 am on Jan 7, 2009 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member

Can you please elaborate on your issues a bit more so that we may help you. Possibly post some relevant code.


6:13 am on Jan 7, 2009 (gmt 0)

5+ Year Member

Here is the code for the form

<p>Fill in the form with all information possible. The date fields will be filled in when being processed.</p>
<form action="form2pdf.php" method="post" enctype="multipart/form-data" onsubmit="MM_validateForm('pname','','R','age','','RisNum','phone','','R','referredby','','R','signedby','','R','notes','','R');return document.MM_returnValue">
<table border="0" cellpadding="1" cellspacing="1">
<td align="left">Patient Name:<br /><input type="text" name="pname" /></td><td align="left">Age:<br /><input type="text" name="age" size="4" /></td>
<td align="left">Phone Number:<br /><input type="text" name="phone" size="15" maxlength="14" /></td><td align="left">Date:<br /><input type="text" name="fdate" disabled="disabled" /></td>
<td colspan="2" align="left">Referred to:<input type="radio" name="referred2" value="Dr. One" />Dr. One<input type="radio" name="referred2" value="Dr Two" />Dr. Two <input type="radio" name="referred2" value="First Available" />First Available</td>
<td colspan="2" align="left">Referred by <input type="text" name="referredby" value="Dr. " /></td>
<td align="left" colspan="2">Please evaluate the following concern(s) and treat as necessary:</td>
<td align="center">
<table border="0">
<td><input type="checkbox" name="develop" value="Developing Malocclusion" />Developing Malocclusion</td><td><input type="checkbox" name="idealtx" value="Determining Ideal Tx Time" />Determining Ideal Tx Time</td>
<td><input type="checkbox" name="habit" value="Habit Control" />Habit Control</td><td><input type="checkbox" name="toothteeth" id="missingteeth" value="Missing Tooth or Teeth" />
Missing Tooth/Teeth</td>
<td><input type="checkbox" name="impactions" value="Impaction(s)" />Impaction(s)</td><td><input name="possibleextractions" type="checkbox" id="possibleextractions" value="Possible Extractions" />
Possible Extractions</td>
<td><input type="checkbox" name="sm" value="Space Maintenance" />Space Maintenance</td><td><input type="checkbox" name="tmj" value="T.M.J. Evaluation" />T.M.J. Evaluation</td>
<td><input type="checkbox" name="limitedt" value="Limited Treatment" />Limited Treatment</td><td><input type="checkbox" name="surgery" value="Possible Surgery" />Possible Surgery</td>
<td colspan="2"><input type="checkbox" name="others" value="Other" />Other<br /><textarea name="other" cols="50"></textarea></td>
<td align="left" colspan="2">Notes:<br />
<textarea name="notes" cols="50"></textarea></td>
<td align="left">Signed:<input type="text" name="signedby" /></td><td align="left">Dated: <input type="text" name="dated" disabled="disabled" /></td>
<td align="left" colspan="2">Preferred Office Location: <input type="radio" name="officeloc" value="Santa Cruz" />Santa Cruz <input type="radio" name="officeloc" value="Aptos" />Aptos</td>
<td colspan="2"><p>Use the fields below to attach x-ray images to this form.</p></td>
echo "<tr><td colspan=2>File #".$i." <input type=file name='fileatt[]'></td></tr>";
<td><input type="submit" name="send" value="Submit" onclick="window.print();window.print();" /></td>

Here is the code for the processing script

<? //heres where the fields are added to the array for the fdf file
$data['toothteeth']=$_POST['toothteeth']; // here is the one field that is not populating. I got one of the checkboxes to populate by deleting it in the pdf and adding it back in. I did so with this one and it didnt work.
$newpname=str_replace(" ","_",$_POST['pname']);
//below is where the fdf is created.
if($fp=fopen($fdf_dir.'/'.$fdf_file, 'w')){
echo $fdf_file.' written successfully.';
} else {
die('Unable to create the file '.$fdf_dir.'/'.$fdf_file);
// Mail code using PHP Mailer
$objMail = new PHPMailer();
$objMail->From = "donotreply@example.us";
$objMail->FromName = "Do Not Reply";
$objMail->Subject = "Referral form and xrays attached";
$objMail->Body = "Hello, Here is the referral form we have sent you.";
$objMail->AddAttachment($fdf_dir.'/'.$fdf_file, $fdf_file);
// Uploading Files
$files['file1']=$fdf_file; // here is where the fdf file is added
$filename=str_replace(" ","_",$filename);
if(file_exists($add)==true) {
// Giving all permission to avoid any problem related to the attachment
// Attaching Files
$objMail->AddAttachment($add, $filename);
// Sending mail

Here is the code in the fdf file.

1 0 obj
/FDF << /Fields [ <</T(pname)/V(Jane Doe)>><</T(age)/V(23)>><</T(phone)/V(555.555.5555)>><</T(fdate)/V(01-07-2009)>><</T(referred2)/V(Dr. One)>><</T(referredby)/V(#*$!x)>><</T(develop)/V(Developing Malocclusion)>><</T(idealtx)/V(Determining Ideal Tx Time)>><</T(habit)/V(Habit Control)>><</T(toothteeth)/V(Missing Tooth or Teeth)>><</T(impactions)/V(Impaction(s))>><</T(possibleextractions)/V(Possible Extractions)>><</T(sm)/V(Space Maintenance)>><</T(tmj)/V(T.M.J. Evaluation)>><</T(limitedt)/V(Limited Treatment)>><</T(surgery)/V(Possible Surgery)>><</T(others)/V(Other)>><</T(other)/V(#*$!)>><</T(notes)/V(#*$!)>><</T(signedby)/V(John Doe)>><</T(dated)/V(01-07-2009)>><</T(officeloc)/V(Santa Cruz)>>]
/F (referralform.pdf) /ID [ <f6f1f8409f930287666df4627559daa4>
] >>
/Root 1 0 R


Any help would be greatly appreciated.

[edited by: coopster at 1:42 pm (utc) on Jan. 7, 2009]
[edit reason] exemplified details [/edit]


8:19 am on Jan 7, 2009 (gmt 0)

10+ Year Member

You should add some error checking to make sure that the file was uploaded properly and that the file isn't so large that it violates the PHP upload_max_file_size or the PHP post_max_size config settings.

Featured Threads

Hot Threads This Week

Hot Threads This Month