i am making simple experiment about html to pdf.i can populate all the textfields but not the check boxes,i used radio button in html so that only one can picked on the two.how can i possibly populate the checkboxes in pdf??please help!
here is my code:
<html>
<body>
<head>
<style>
form
{
border: 15px solid black;
background-color:skyblue;
padding: 5px;
}
input
{
background-color: white;
}
select
{
background-color:skyblue;
color: black;
font-size:16px;
}
textarea
{
background-color: blue;
color: white;
}
.texta
{
font-size 16px;
background-color:#cccccccc;
border: 1px solid #66666;
}
</style>
</head>
<form method="post" action="http://localhost/fpdf/submit_form.php">
<fieldset>
<table border = 1 bgcolor = "skyblue" width= 100% height = 40% align = left>
<tr height = 30%><td valign = top>
<legend>Student Details</legend>
<div class = "line">Family Name</div><input type="text" name="Fname" />
<div class = "line">Given Name</div><input type="text" name="Gname" />
<div class = "line">Preferred Name</div><input type="text" name="Pname" />
<div class = "line">Proposed Commencement Date</div><input type="text" name="PCD" />
<div class = "line">Proposed Length of course (weeks)</div><input type="text" name="PLOC" />
<div class = "line">Date Of Birth (dd/mm/yy)</div><input type="text" name="DOB" />
<div class = "line">Gender</div>
<label>Male</label><input unchecked "selected" type="radio" name="sex" value = "male" />
<label>Female</label><input unChecked = "selected" type="radio" name="sex" value = "female"/>
<div class = "line">Parents Name if under 18</div><input type="text" name="Parname" />
<div class = "line">Country of Birth</div><input type="text" name="COB" />
<div class = "line">Current Overseas Address</div><input type="text" name="COA" />
<div class = "line">Email Address</div><input type="text" name="Eadd" />
<div class = "line">Next of Kin</div><input type="text" name="NOK" />
<div class = "line">Next of Kin Address</div><input type="text" name="NOKA" />
<div class = "line">Next of Kin Telephone</div><input type="text" name="NOKT" />
</td>
<td valign = top>
<legend>Background Information</legend></br>
<div>Guidance Officer</div>
<label>Yes</label><input unchecked "selected" type="radio" name="r1" value = "yes" />
<label>No<label><input unChecked = "selected" type="radio" name="r1" value = "no"/>
<div>Councelor</div></br>
<label>Yes</label><input unchecked "selected" type="radio" name="r2" value = "yes" />
<label>No</label><input unChecked = "selected" type="radio" name="r2" value = "no"/>
<div>Psychologist</div></br>
<label>Yes</label><input unchecked "selected" type="radio" name="r3" value = "yes" />
<label>No</label><input unChecked = "selected" type="radio" name="r3" value = "no"/>
<div>Hearing Impaired Services</div></br>
<label>Yes</label><input unchecked "selected" type="radio" name="r4" value = "yes" />
<label>No</label><input unChecked = "selected" type="radio" name="r4" value = "no"/>
<div>Physically Handicapped Services</div></br>
<label>Yes</label><input unchecked "selected" type="radio" name="r5" value = "yes" />
<label>No</label><input unChecked = "selected" type="radio" name="r5" value = "no"/>
<div>Visual Services</div></br>
<label>Yes</label><input unchecked "selected" type="radio" name="r6" value = "yes" />
<label>No</label><input unChecked = "selected" type="radio" name="r6" value = "no"/>
<div>Speech Therapist</div></br>
<label>Yes</label><input unchecked "selected" type="radio" name="r7" value = "yes" />
<label>No</label><input unChecked = "selected" type="radio" name="r7" value = "no"/>
</td></tr>
<tr height = 70%><td valign = top>
<legend>Educational History</legend></br>
<div class = "line">How many years of schooling have you completed?</div><input type="text" name="Yschool"/>
<div class = "line">How long have you learned English?</div><input type="text" name="Lenglish" />
</td>
<td valign = top>
<legend>Academic Details</legend></br>
<div class = "line">Present Education Institution</div><input type="text" name="PEI" />
<div class = "line">Education Institution Address</div><input type="text" name="EIA" />
<div class = "line">IELTS Test Score</div><input type="text" name="ITscore" />
<div class = "line">Highest level of Education achieved in home country</div><input type="text" name="Eachieved" />
<div class = "line">If not still attending - date of last attendance</div><input type="text" name="Lattend" />
</td></tr>
</table>
</fieldset>
<fieldset>
<table border = 1 bgcolor = "skyblue" width= 100% height = 40% align = left>
<tr height = 30%><td valign = top>
<legend>Course Details</legend></br>
<div class = "line">Proposed start date of course</div><input type="text" name="SDcourse" /></br>
<div>Proposed tertiary level course (Univ/Vet)</div>
<label>Certificate II</label><input checked='yes' "selected" type="radio" name="r8" value = "CertificateII" />
<label>Certificate III</label><input unChecked = "selected" type="radio" name="r8" value = "CertificateIII"/>
<label>Certificate IV</label><input unChecked = "selected" type="radio" name="r8" value = "CertificateIV"/></br>
<labrl>Other:</label><input type="text" name="TLcourse" />
</td></tr>
</table>
</fieldset>
<fieldset>
<table>
<input type="submit" value="Generate FDF Data" />
</table>
</fieldset>
</form>
<?php
echo '<pre>'; print_r($_POST); echo '</pre>';
?>
<?php
if(isset($_POST) && is_array($_POST) && count($_POST))
{
$data=array();
echo'<pre>POST '; print_r($_POST);
echo '</pre>';
if(isset($_POST['Fname']))
{
$pat='`[^a-z0-9\s]+$`i';
if(empty($_POST['Fname']) || preg_match($pat,$_POST['Fname']))
{
die('Invalid input for Fname field.');
}
else
{
$data['Fname']=$_POST['Fname'];
}
$img= "<img src='check.png' width='15' height='17' alt='airportindicator'>";
if(isset($_POST['sex']) && $_POST['sex'] == 'male')
{
echo "Male";
}
else
{
echo "Female";
}
$data['Family Name']=$_POST['Fname'];
$data['Gname']=$_POST['Gname'];
$data['Pname']=$_POST['Pname'];
$data['PCD']=$_POST['PCD'];
$data['PLOC']=$_POST['PLOC'];
$data['DOB']=$_POST['DOB'];
$data['sex']=$_POST['male'];
$data['sex']=$_POST['female'];
$data['Parname']=$_POST['Parname'];
$data['COB']=$_POST['COB'];
$data['COA']=$_POST['COA'];
$data['Eadd']=$_POST['Eadd'];
$data['NOK']=$_POST['NOK'];
$data['NOKA']=$_POST['NOKA'];
$data['NOKT']=$_POST['NOKT'];
$data['Yschool']=$_POST['Yschool'];
$data['Lenglish']=$_POST['Lenglish'];
$data['PEI']=$_POST['PEI'];
$data['EIA']=$_POST['EIA'];
$data['ITscore']=$_POST['ITscore'];
$data['Eachieved']=$_POST['Eachieved'];
$data['Lattend']=$_POST['Lattend'];
$data['SDcourse']=$_POST['SDcourse'];
$data['TLcourse']=$_POST['TLcourse'];
require_once 'createFDF.php';
$fdf_file=time().'.fdf';
$fdf_dir=dirname(__FILE__).'\\results';
$pdf_doc='http://localhost/fpdf/ATTC2.pdf';
$fdf_data=createFDF($pdf_doc,$data);
if($fp=fopen($fdf_dir.'\\'.$fdf_file,'w'))
{
fwrite($fp,$fdf_data,strlen($fdf_data));
echo $fdf_file,' written successfully.';
}
else
{
die('Unable to create file: '.$fdf_dir.'\\'.$fdf_file);
}
fclose($fp);
}
}
else
{
echo 'You did not submit a form.';
}
?>
</html>
don