Creating a CSV from a web form output - php

I'm currently trying to make a web form such that when a user enters their information (they're applying for a service upgrade), their application will be put through to a CSV file.
I've created my web form, albeit very roughly as I'm not skilled in web dev/design. This is it here:
<!DOCTYPE html>
<html>
<style type="text/css">
.fieldset-auto-width {
display:inline;
}
form {
text-align: center;
}
select.my_dropdown {
width:130px;
}
</style>
<head>
<!-- head stuff goes here -->
<script src="users.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" ></script>
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js" ></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" >
</head>
<body>
<h2 align="center"><u>Service Request Application Form</u></h2>
<hr>
<?php
if($_POST['formSubmit'] == "Submit Application")
{
$fn = $_POST['CustomerName'];
}
?>
<form method="post" align="center" name="myForm" id="applicationform" action="export.php">
<!--###################################### CONTACT INFORMATION FIELDSET ######################################-->
<fieldset style="border: 1px black solid">
<legend style="font-weight:bold"><u>Contact Information</u></legend>
<table>
<tr>
<th></th>
<th><u>Customer</u></th>
<th title="Electrician"><u>Consultant/Contractor</u></th>
</tr>
<tr>
<td>
<tr>
<td align="right" id="namelabel">Contact Name:</td>
<td><input type="text" id="customername" name="CustomerName" title="Name of contact on account"/></td>
<td><input type="text" id="contractorname" name="ContractorName" title="Name of contractor or consultant" /></td>
</tr>
<tr>
<td align="right" id="addresslabel">Mailing Address:</td>
<td><input type="text" id="customeraddress" name="CustomerMailingAddress" title="Enter your mailing address"/></td>
<td><input type="text" id="contractoraddress" name="ContractorMailingAddress" title="Enter your contractor's mailing address" /></td>
</tr>
<tr>
<td align="right" id="phonelabel">Phone Number:</td>
<td><input type="text" id="customerphone" name="CustomerPhoneNumber" title="Enter your phone number here" /></td>
<td><input type="text" id="contractorphone" name="ContractorPhoneNumber" title="Enter contractor's phone number here" /></td>
</tr>
<tr>
<td align="right" id="mobilephonelabel">Mobile Number:</td>
<td><input type="text" id="customermobilephone" name="CustomerMobilePhoneNumber" title="Enter your mobile phone number here"/></td>
<td><input type="text" id="contractormobilephone" name="ContractorMobilePhoneNumber" title="Enter contractor's mobile phone number here"/></td>
</tr>
<tr>
<td align="right" id="faxlabel">Fax:</td>
<td><input type="text" id="customerfax" name="CustomerFax" title="Enter fax information here" /></td>
<td><input type="text" id="contractorfax" name="ContractorFax" title="Enter fax information here"/></td>
</tr>
<tr>
<td align="right" id="emaillabel">E-mail:</td>
<td><input type="text" id="customeremail" name="CustomerEmail" title="Enter your email address here" /></td>
<td><input type="text" id="contractoremail" name="ContractorEmail" title="Enter contractor's email address here" /></td>
</tr>
<tr>
<td align="right" id="accountnumberlabel">Account Number:</td>
<td colspan="2"><input type="text" id="accountnumber" name="AccountNumber" size="46" title="Enter account number for requested upgrade here"/></td>
</tr>
</td>
</tr>
</table>
</fieldset>
<!--###################################### SERVICE INFORMATION FIELDSET ######################################-->
<fieldset style="border: 1px black solid">
<legend style="font-weight:bold"><u>Service Information</u></legend>
<table>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<td>
<tr>
<td align="right" id="serviceaddresslabel">Service Address:</td>
<td><input type="text" id="serviceaddress" name="ServiceAddress" title="Location of requested service"/></td>
</tr>
<tr>
<td align="right" id="unitlabel">Unit #:</td>
<td align="left"><input type="text" id="unitnumber" name="UnitNumber" title="Unit for requested service"/></td>
</tr>
<tr>
<td align="right" id="servicetypelabel">Service Type:</td>
<td align="left">
<select class="my_dropdown" name="ServiceType" id="servicetype" title="Select the type of service you require">
<option value="-1" selected>[select--service]</option>
<option value="1">Upgrade</option>
<option value="2">Temporary</option>
<option value="3">New Permanent</option>
<option value="4">Other</option>
</select>
</td>
</tr>
<tr>
<td align="right" id="customerclasslabel">Customer Class:</td>
<td align="left">
<select class="my_dropdown" name="CustomerClass" id="customerclass" title="Select the type of account the service is for">
<option value="-1" selected>[select--type]</option>
<option value="1">Residential</option>
<option value="2">Commercial</option>
<option value="3">Industrial</option>
</select>
</td>
</tr>
<tr>
<td align="right" id="proposedloadlabel">Proposed Load:</td>
<td align="left"><input type="text" id="proposedload" name="ProposedLoad" size="10" title="Enter the proposed Kilowatt load the upgrade will handle"/>kW</td>
</tr>
<tr>
<td align="right" id="proposedmainlabel">Proposed Main Switch:</td>
<td align="left"><input type="text" id="proposedmainswitch" name="ProposedMainSwitch" size="10" title="Enter the proposed Amperage (Amps) load the main switch will handle"/>A</td>
<td align="left" id="existingmainlabel">Existing Main Switch:</td>
<td align="left"><input type="text" id="existingmainswitch" name="ExistingMainSwitch" title="Enter the current Amperage load the main switch handles"size="10"/>A</td>
</tr>
<tr>
<td align="right" id="voltagelabel">Voltage:</td>
<td align="left">
<select class="my_dropdown" name="Voltage" id="voltage" title="Select the Voltage rating required">
<option value="-1" selected>[select--voltage]</option>
<option value="1">240/120V</option>
<option value="2">208/120V</option>
<option value="3">600/347V</option>
</select>
</td>
</tr>
<tr>
<td align="right" id="phaselabel">Phase:</td>
<td align="left">
<select class="my_dropdown" name="Phase" id="phase" title="Select the upgrade phase preferred">
<option value="-1" selected>[select--phase]</option>
<option value="1">Single-Phase</option>
<option value="2">Three-Phase</option>
</select>
</td>
</tr>
<tr>
<td align="right" id="powersupplylabel">Power Supply:</td>
<td align="left">
<select class="my_dropdown" name="PowerSupply" id="powersupply" width="90" title="Select position of power supply required">
<option value="-1" selected size>[select--supply]</option>
<option value="1">Overhead (OH)</option>
<option value="2">Underground (UG)</option>
<option value="3">OH to UG</option>
<option value="4">UG to OH</option>
</select>
</td>
</tr>
<tr>
<td align="right" id="meterbaselabel">Meter Base Location:</td>
<td align="left">
<select class="my_dropdown" name="MeterBaseLocation" id="MeterBaseLocation" title="Select the location of the Meter">
<option value="-1" selected>[select--location]</option>
<option value="1">Existing Outside</option>
<option value="2">Inside Moving Out</option>
<option value="3">Relocate</option>
<option value="4">Ganged Position*</option>
</select>
<td align="left"><input type="text" id="existingmainswitch" name="ExistingMainSwitch" size="5" title="If meter location requires a Ganged (multiple) position installation, how many positions are needed?"/>*Positions</td>
</td>
</tr>
</td>
</tr>
</table>
</fieldset>
<table>
<tr>
<td align="center" id="commentslabel" title="Anything you want to add? Tell us here"><b><u>Comments/Reason for Upgrade:</b></u></td>
</tr>
<tr>
<td><textarea align="center" id="comments" rows="4" cols="80" style="border: 1px black solid" title="Anything you want to add? Tell us here"></textarea></td>
</tr>
<tr>
<td align="left">
<input type="checkbox" align="left" id="consent" value="consent1"><b> I confirm that the information I have given in this form is true to the best of my knowledge.</b><br>
<input type="checkbox" align="left" id="consent" value="consent2"><b>
I acknowledge and accept that if we schedule the connection to be done after hours (3:30PM) a charge
of $415 + HST will be added to my electricity bill for the month. </b><br>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="formSubmit" value="Submit Application"></td>
</tr>
</table>
</form>
</body>
I've created a 'starter' file to test my form. I've only included a few variables for field testing as I'm not sure if I'm doing it the right way to output it to a CSV file. (CSV output required by employer)
Here is my action handler file named export.php:
<?php
$fn = $_POST['customername'];
$ln = $_POST['contractorname'];
// $address = $_POST['address'];
//validate
if(empty($fn) || empty($ln) || empty($address) || empty($city) || empty($state) || empty($zip) || empty($phone) || empty($email)){//show the form
$message = 'Fill in areas in red!';
$aClass = 'errorClass';
}
//this is where the creating of the csv takes place
$cvsData = $fn . "," . $ln ."\n";
$fp = fopen("formTest.csv","a"); // $fp is now the file pointer to file $filename
if($fp){
fwrite($fp,$cvsData); // Write information to the file
fclose($fp); // Close the file
}
?>
I am trying to output to a file for testing named formTest.csv. Currently I believe I'm having issues with PHP on my PC at work, as the network admins restrict access on our computers they were the ones who set it up while I was away. Currently when I click submit it just opens my export.php page, which is why I say my issue is PHP on my machine. But when I tested this on my home PC which SHOULD have PHP working (but it has been a while), it would return to my form but nothing would be input into the CSV.
Any tips?

Related

PHP Form CSS & Positioning

Thank you for taking the time to read/answer this.
First thing: my career page has a pre-made contact form that i turned into a job application. I have two layout questions:
1.) How do i get the 'checkbox' buttons to line up a little closer to each other. I tried td colspan="2" which is the case later in the form for 2 buttons (submit/reset 1 which i removed), but to no avail, "No" appears well to the right of "Yes." I'd like to have it relatively closer to "Yes."
2.) When you pull the drop down for "Experience" down, it forces the image below the form. Once you select your option, the image goes back to its place. Do i absolutely have to absolute position the graphic? Or can i add an overflow maybe to the dropdown? I can't figure it out.
FancyForm is the form i'm using.
Here is the HTML:
<form id="contact-form" name="contact-form" method="post" action="submit.php">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="15%"><label for="name">Name</label></td>
<td width="70%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="<?=$_SESSION['post']['name']?>" /></td>
<td width="15%" id="errOffset"> </td>
</tr>
<tr>
<td width="15%"><label for="address">Address</label></td>
<td width="70%"><input type="text" class="validate[required,custom[a-zA-Z\d\s\-\,\#\.\+]+]" name="address" id="address" value="<?=$_SESSION['post']['address']?>" /></td>
<td width="15%" id="errOffset"> </td>
</tr>
<tr>
<td width="15%"><label for="telephone">Telephone</label></td>
<td width="70%"><input type="text" class="validate[required,custom[onlyNumber]]" name="telephone" id="telephone" value="<?=$_SESSION['post']['telephone']?>" /></td>
<td width="15%" id="errOffset"> </td>
</tr>
<tr>
<td width="15%"><label for="email">Email</label></td>
<td width="70%"><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td>
<td width="15%" id="errOffset"> </td>
</tr>
<tr>
<td width="15%"><label for="citizenship">US Citizen</label></td>
<td width="35%"><input type="checkbox" name="citizen" value="yes">Yes</td>
<td width="35%"><input type="checkbox" name="citizen" value="no">No</td>
<td width="15%" id="errOffset"> </td>
</tr>
<tr>
<td width="15%"><label for="age">At Least 18</label></td>
<td width="35%"><input type="checkbox" name="age" value="yes">Yes</td>
<td width="35%"><input type="checkbox" name="age" value="no">No</td>
<td width="15%" id="errOffset"> </td>
</tr>
<tr>
<td width="15%"><label for="previousexp">Have you worked<br> with us before?</label></td>
<td width="35%"><input type="checkbox" name="previousexp" value="yes">Yes
<td width="35%"><input type="checkbox" name="previousexp" value="no">No</td>
<td width="15%" id="errOffset"> </td>
</tr>
<tr>
<td width="15%"><label for="subject">Experience</label></td>
<td width="70%"><select name="subject" id="subject">
<option value="" selected="selected"> - Choose -</option>
<option value="0-5">0-5 Years</option>
<option value="6-10">6-10 Years</option>
<option value="11-15">11-15 Years</option>
<option value="16-20">16-20 Years</option>
</select></td>
<td width="15%" id="errOffset"> </td>
</tr>
<tr>
<td><label for="captcha"><?=$_SESSION['n1']?> + <?=$_SESSION['n2']?> =</label></td>
<td><input type="text" class="validate[required,custom[onlyNumber]]" name="captcha" id="captcha" /></td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
<td colspan="2"><input type="submit" name="button" id="button" value="Submit" />
<?=$str?> <img id="loading" src="img/ajax-load.gif" width="16" height="16" alt="loading" /></td>
</tr>
</table>
</form>
CSS:
#form-container{
padding:0px;
}
td{
white-space:nowrap;
}
h1{
color:#777777;
font-size:22px;
font-weight:normal;
text-transform:uppercase;
margin-bottom:5px;
}
h2{
font-weight:normal;
font-size:10px;
text-transform:uppercase;
color:#aaaaaa;
margin-bottom:15px;
border-bottom:1px solid #484848;
margin-bottom:15px;
}
label{
text-transform:uppercase;
font-size:10px;
font-family:Tahoma,Arial,Sans-serif;
}
textarea{
color:#404040;
font-family:Arial,Helvetica,sans-serif;
font-size:12px;
}
td > button{
text-indent:8px;
}
Thank you very much for trying to help <3
Remove overflow:auto from id #wrapper for your image problem
For your first question, you can simply place both checkboxes in the same <td></td> to get them side-by-side. Change the code to:
<td width="35%"><input type="checkbox" name="citizen" value="yes">Yes<input type="checkbox" name="citizen" value="no">No</td>
As for the image, you don't seem to have included the code pertaining to it. If you could provide the code in context around this Form so I could see how the image is being placed, it would aid in discovering why it's moving.

how to upload photos with other detail like username, email , mobie etc

Here is my code to upload a Single Image. But i want to upload 3 images at a time.
How can i do it ?
<form enctype="multipart/form-data" action="process2.php" method="POST">
<table id="tbl1">
<tr>
<td>For Sale </td>
<td colspan="2">
<input type="hidden" name="id"/>
</td>
</tr>
<tr>
<td>Type: </td>
<td colspan="2">
<select name="type" id="slct"><option>Residential</option></select></td>
</tr>
<tr>
<td>State: </td><td colspan="2">
<select name="state" id="slct"><option>Punjab</option></select></td>
</tr>
<tr>
<td>City: </td><td colspan="2">
<select name="city" id="slct"><option>Lahore</option></select></td>
</tr>
<tr>
<td>Location: </td><td colspan="2">
<input name="location" placeholder="Enter Location Here" id="slct2" type="text" /></td>
</tr>
<tr>
<td>Bedrooms:</td><td colspan="2">
<select name="bedroom"><option>1</option></select></td>
</tr>
<tr>
<td>Land In: </td><td colspan="2">
<select name="landtype" id="slct"><option>Kanal</option></select>
</tr>
<tr>
<td>Land Area: </td><td colspan="2">
<input name="landarea" placeholder="Enter area here" id="slct2" type="text" /></td>
</tr>
<tr>
<td>Price: </td><td colspan="2">
<input name="price" placeholder="Enter price here" id="slct2" type="text" /></td>
</tr>
<tr>
<td>Photo</td>
<td ><input type="file" name="photo" id="file"/></td>
</tr>
<tr>
<td>User Details</td>
<td colspan="2">
</td>
</tr>
<tr>
<td>Name: </td><td colspan="2">
<input name="name" placeholder="full name" id="slct2" type="text" /></td>
</tr>
<tr>
<td>Mobile: </td><td colspan="2">
<input name="mobile" placeholder="format 03001234567" id="slct2" type="text" /></td>
</tr>
<tr>
<td>E-mail: </td><td colspan="2">
<input name="email" placeholder="Enter email Here" id="slct2" type="text" /></td>
</tr>
<tr>
<td></td><td colspan="2"><input type="submit" name="submit" value="Post"/></td>
</tr>
</table>
</form>
add code in HTML
<td>Photo1</td><td ><input type="file" name="photo1" id="file1"/></td>
<td>Photo2</td><td ><input type="file" name="photo2" id="file2"/></td>
Add this code in your html and check selected images in your "process2.php" those are selected that store in your database.
When you insert this images in your database that time just do "img1,img2,img3" store this in your image colum... This is the simplest way if your requirement is only 3 images then you can follow this.

Insert a form in a jquery tab to submit data in database using php

I am using a form to submit data in three different tables, it is actually is a simple form with one submit button.
But now I want the form to be divided in three different tabs each having a button, when the page is loaded first tab should be opened with a form having personal details with a proceed button on clicking proceed button second tab should open up containing another part of form and same goes to final tab having a submit button.
I am not getting it how can it be done with php and JQuery tab.
this was the code i wrote
<script type="text/javascript">
function OtherWork(val){
var element=document.getElementById('wtype');
if(val=='other')
element.style.display='block';
else
element.style.display='none';
}
</script>
<h2>Add New Entry</h2>
<hr />
<form action="processnewentry.php" method="post" name="myForm" onsubmit="return validateForm();" >
<table width="560" border="0" cellspacing="5" cellpadding="0">
<tr>
<td width="234">Lead Name :</td>
<td width="311"><input type="text" name="lename" /></td>
</tr>
<tr>
<td width="234">Lead Date : (mm/dd/yyyy)</td>
<td width="311"><input type="text" name="ldate" class="datepicker" /></td>
</tr>
<tr>
<td width="234">Contact Person :</td>
<td width="311"><input type="text" name="conper" /></td>
</tr>
<tr>
<td width="234">Company Name :</td>
<td width="311"><input type="text" name="cname" /></td>
</tr>
<tr>
<td width="234">Mobile No. :</td>
<td width="311"><input type="text" name="mobno" /></td>
</tr>
<tr>
<td width="234">Landline No. :</td>
<td width="311"><input type="text" name="phone" /></td>
</tr>
<tr>
<td width="234">Address :</td>
<td width="311"><textarea name="address" ></textarea></td>
</tr>
<tr>
<td width="234">Email :</td>
<td width="311"><input type="text" name="email" /></td>
</tr>
<tr>
<td width="234">Alt Address :</td>
<td width="311"><textarea name="altaddress" ></textarea></td>
</tr>
<tr>
<td width="234">Work Type :</td>
<td width="311"><select name="wtype" onchange='OtherWork(this.value);'>
<option value="Website Designing">Website Designing</option>
<option value="Android Application">Android Application</option>
<option value="other">Other</option>
</select><br />
<input type="text" name="wtype" id="wtype" style='display:none;'/>
</td>
</select>
</tr>
<tr>
<td width="234">Work Description :</td>
<td width="311"><textarea name="wdesc" ></textarea></td>
</tr>
<tr>
<td width="234">Expected Budget :</td>
<td width="311"><input type="text" name="exbudget" /></td>
</tr>
<tr>
<td width="234">Lead Executive :</td>
<td width="311"><select name="lexec">
<?php
$q=mysql_query('SELECT * FROM $table');
while($rr=mysql_fetch_array($q))
{
$na=$rr['name'];
?>
<option value="<?php echo $na;?>"><?php echo strtoupper($na);?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td width="234">Lead Manager :</td>
<td width="311"><select name="lmana">
<?php
$q=mysql_query('SELECT * FROM $table');
while($rr=mysql_fetch_array($q))
{
$na=$rr['name'];
?>
<option value="<?php echo $na;?>"><?php echo strtoupper($na);?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td width="234">Closing Date : (mm/dd/yyyy)</td>
<td width="311"><input type="text" name="cldate" class="datepicker" /></td>
</tr>
<tr>
<td width="234">Lead Status :</td>
<td width="311"><select name="lstat">
<option value="Hot">Hot</option>
<option value="Warm">Warm</option>
<option value="Cold">Cold</option>
</select></td>
</tr>
<tr>
<td width="234">Follow Up :</td>
<td width="311"><textarea name="followup" ></textarea></td>
</tr>
<tr>
<td width="234">Next Follow up : (mm/dd/yyyy)</td>
<td width="311"><input type="text" name="nfoldate" class="datepicker" /></td>
</tr>
<tr>
<td width="234">Remark if any :</td>
<td width="311"><textarea name="remark" ></textarea></td>
</tr>
<tr>
<td width="234"> </td>
<td width="311"><input name="submit" type="submit" value="Submit" class="buttton" /></td>
</tr>
</table>
</form>
your form is having 3 parts(i.ir 3 different tabs).So give 3 different html classes to its fields.Eg.
fields on first tab will look like :
fields on first tab will look like :
fields on first tab will look like :
At first, fields on second and third tab would be display none.
Now on click of first proceed button, validate fields(if required) and then, make fields on first tab display none using jquery(i.e. add css property)
Eg.
$("#first_proceed").click(function(){
$(".first").css("display","none");
})
Same for second proceed button.
And on click of third button(i.e. submit), Submit your form

Messed up HTML/CSS design [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I'm just checking other people's works and Im fixing this design and I can't seem to have an idea on how to fix it. I don't want to change anything from the css so is it possible to just arrange it on html?
<!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" />
<title>Clinical Module</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="inc/style.css" type="text/css">
</head>
<body>
<form action='' method='POST'><center>
<input type="text" placeholder="Patient Number" name="search" > <input type="submit" Value="Check" name='submit'> <br>
<?php
mysql_connect("localhost","root","");
mysql_select_db("invoices");
$search = 0;
$search=$_POST['search'];
if (isset($_POST['submit'])){
$query = "select * from `patient` where `clientid` = $search ";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)){ ?>
First name:<br>
</td>
<td valign="top" align="left">
<input type="text" size="20" name="first_name" value="<?php echo $row["first_name"]?>" ></td>
<td valign="top" width="10%" rowspan="13">
</td>
</tr>
<tr>
<td valign="top" align="right">
Middle name:</td>
<td valign="top" align="left">
<input type="text" size="20" name="middle_name" value="<?php echo $row["middle_name"]?>" ></td>
</td>
</tr>
<tr>
<td valign="top" align="right">
Last Name:
</td>
<td valign="top" align="left">
<input type="text" name="last_name" size="20" value="<?php echo $row["last_name"]?>"></td>
</tr>
<tr>
<td valign="top" align="right">
Birthdate
</td>
<td valign="top" align="left">
<input type="text" name="Birthdate" size="20" value="<?php echo $row["birthdate"]; ?>"></td>
</tr>
<tr>
<td valign="top" align="right">
Age
</td>
<td valign="top" align="left">
<input readonly type="text" name="age" size="20" value="<?php echo $row["age"]?>" placeholder="YYYY-MM-DD"></td>
</tr>
<tr>
<td valign="top" align="right"> Gender:</td>
<td valign="top" align="left"><select name="gender">
<? if ($row["gender"]==Male) { ?>
<option value="Male" selected>Male</option>
<option value="Female">Female</option>
<? }else if ($row["gender"]==Female) { ?>
<option value="Male" >Male</option>
<option value="Female" selected>Female</option> <?php }?>
</select></tr>
</td><tr>
<td valign="top" align="right"> Civil Status:</td>
<td valign="top" align="left"><select name="civil_status">
<? if ($row["civil_status"]==Single) { ?>
<option value="Single" selected >Single</option>
<option value="Married">Married</option>
<option value="Separatede">Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Married) { ?>
<option value="Single" >Single</option>
<option value="Married" selected>Married</option>
<option value="Separated">Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Separated) { ?>
<option value="Single" >Single</option>
<option value="Married">Married</option>
<option value="Separated" selected>Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Widowed) { ?>
<option value="Single" >Single</option>
<option value="Married">Married</option>
<option value="Separated">Separated</option>
<option value="Widowed" selected>Windowed</option> <?php }?>
</select>
</td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Address:</td>
<td valign="top" align="left">
<input type="text" name="address" value="<?php echo $row["address"]?>" size="31"></td>
</tr>
<tr>
<td valign="top" align="right">
Tel. no.:</td>
<td valign="top" align="left">
<input
type="text" size="20" name="telno" placeholder="###-####" value="<?php echo $row["telno"]?>"></td></tr>
<tr>
<td valign="top" align="right">
Occupation:</td>
<td valign="top" align="left">
<input
type="text" size="20" name="occ" value="<?php echo $row["occ"]?>"></td></tr>
<tr>
<td align="right">
Spouse:</td>
<td >
<input
type="text" size="20" name="spo" value="<?php echo $row["spo"]?>"></td></tr><tr>
<td align="right">
Occupation:</td>
<td >
<input
type="text" size="20" name="occ2" value="<?php echo $row["occ2"]?>"></td></tr>
<tr>
<td align="right" width="20">
Contact Person(in case of emergency):</td>
<td >
<input
type="text" size="20" name="cp" value="<?php echo $row["cp"]?>"></td></tr><tr>
<td align="right">
Tel. no:</td>
<td >
<input
type="text" size="20" name="tel2" value="<?php echo $row["tel2"]?>"></td></tr>
<tr>
<td valign="top" align="right" nowrap>
Reffered By:</td>
<td valign="top" align="left">
<input type="text" name="reff" value="<?php echo $row["reff"]?>" size="31" ></td>
</tr>
<tr>
<td class=topHeadrow1 valign="middle" width="50%" colspan="2">
Past Medical History:</td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Allergy:</td>
<td valign="top" align="left">
<input type="text" name="all" value="<?php echo $row["all"]?>" size="31"></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Previous illness:</td>
<td valign="top" align="left">
<input type="text" name="ill" value="<?php echo $row["ill"]?>" size="31"></td>
</tr>
<tr>
<td class=topHeadrow1 valign="middle" width="50%" colspan="2">
<b><font size="4">
Heredo-Familial Diseases:</font></b></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Maternal:
</td>
<td valign="top" align="left">
<input type="text" name="mat" value="<?php echo $row["mat"]?>" size="20"></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Fraternal:
</td>
<td valign="top" align="left">
<input type="text" name="frat" value="<?php echo $row["frat"]?>" size="20"></td>
</tr>
<? }
}
?>
</center>
</form>
|
I'm not sure if this is what you are referring to, as you've not specified a massive amount of information...
However,
You don't seem to have the actual <table> or </table> tags on this form...
No, opening <tr> tag (as pointed out by Tim Medora Below... Thanks!)...
And also no beginning <td valign="top" align="right"> Before your First name:<br>
<!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" />
<title>Clinical Module</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="inc/style.css" type="text/css">
</head>
<body>
<form action='' method='POST'><center>
<input type="text" placeholder="Patient Number" name="search" > <input type="submit" Value="Check" name='submit'> <br>
<table>
<?php
mysql_connect("localhost","root","");
mysql_select_db("invoices");
$search = 0;
$search=$_POST['search'];
if (isset($_POST['submit'])){
$query = "select * from `patient` where `clientid` = $search ";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)){ ?>
<tr>
<td valign="top" align="right">
First name:<br>
</td>
<td valign="top" align="left">
<input type="text" size="20" name="first_name" value="<?php echo $row["first_name"]?>" ></td>
<td valign="top" width="10%" rowspan="13">
</td>
</tr>
<tr>
<td valign="top" align="right">
Middle name:</td>
<td valign="top" align="left">
<input type="text" size="20" name="middle_name" value="<?php echo $row["middle_name"]?>" ></td>
</td>
</tr>
<tr>
<td valign="top" align="right">
Last Name:
</td>
<td valign="top" align="left">
<input type="text" name="last_name" size="20" value="<?php echo $row["last_name"]?>"></td>
</tr>
<tr>
<td valign="top" align="right">
Birthdate
</td>
<td valign="top" align="left">
<input type="text" name="Birthdate" size="20" value="<?php echo $row["birthdate"]; ?>"></td>
</tr>
<tr>
<td valign="top" align="right">
Age
</td>
<td valign="top" align="left">
<input readonly type="text" name="age" size="20" value="<?php echo $row["age"]?>" placeholder="YYYY-MM-DD"></td>
</tr>
<tr>
<td valign="top" align="right"> Gender:</td>
<td valign="top" align="left"><select name="gender">
<? if ($row["gender"]==Male) { ?>
<option value="Male" selected>Male</option>
<option value="Female">Female</option>
<? }else if ($row["gender"]==Female) { ?>
<option value="Male" >Male</option>
<option value="Female" selected>Female</option> <?php }?>
</select></tr>
</td><tr>
<td valign="top" align="right"> Civil Status:</td>
<td valign="top" align="left"><select name="civil_status">
<? if ($row["civil_status"]==Single) { ?>
<option value="Single" selected >Single</option>
<option value="Married">Married</option>
<option value="Separatede">Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Married) { ?>
<option value="Single" >Single</option>
<option value="Married" selected>Married</option>
<option value="Separated">Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Separated) { ?>
<option value="Single" >Single</option>
<option value="Married">Married</option>
<option value="Separated" selected>Separated</option>
<option value="Widowed">Windowed</option>
<? }else if ($row["civil_status"]==Widowed) { ?>
<option value="Single" >Single</option>
<option value="Married">Married</option>
<option value="Separated">Separated</option>
<option value="Widowed" selected>Windowed</option> <?php }?>
</select>
</td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Address:</td>
<td valign="top" align="left">
<input type="text" name="address" value="<?php echo $row["address"]?>" size="31"></td>
</tr>
<tr>
<td valign="top" align="right">
Tel. no.:</td>
<td valign="top" align="left">
<input
type="text" size="20" name="telno" placeholder="###-####" value="<?php echo $row["telno"]?>"></td></tr>
<tr>
<td valign="top" align="right">
Occupation:</td>
<td valign="top" align="left">
<input
type="text" size="20" name="occ" value="<?php echo $row["occ"]?>"></td></tr>
<tr>
<td align="right">
Spouse:</td>
<td >
<input
type="text" size="20" name="spo" value="<?php echo $row["spo"]?>"></td></tr><tr>
<td align="right">
Occupation:</td>
<td >
<input
type="text" size="20" name="occ2" value="<?php echo $row["occ2"]?>"></td></tr>
<tr>
<td align="right" width="20">
Contact Person(in case of emergency):</td>
<td >
<input
type="text" size="20" name="cp" value="<?php echo $row["cp"]?>"></td></tr><tr>
<td align="right">
Tel. no:</td>
<td >
<input
type="text" size="20" name="tel2" value="<?php echo $row["tel2"]?>"></td></tr>
<tr>
<td valign="top" align="right" nowrap>
Reffered By:</td>
<td valign="top" align="left">
<input type="text" name="reff" value="<?php echo $row["reff"]?>" size="31" ></td>
</tr>
<tr>
<td class=topHeadrow1 valign="middle" width="50%" colspan="2">
Past Medical History:</td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Allergy:</td>
<td valign="top" align="left">
<input type="text" name="all" value="<?php echo $row["all"]?>" size="31"></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Previous illness:</td>
<td valign="top" align="left">
<input type="text" name="ill" value="<?php echo $row["ill"]?>" size="31"></td>
</tr>
<tr>
<td class=topHeadrow1 valign="middle" width="50%" colspan="2">
<b><font size="4">
Heredo-Familial Diseases:</font></b></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Maternal:
</td>
<td valign="top" align="left">
<input type="text" name="mat" value="<?php echo $row["mat"]?>" size="20"></td>
</tr>
<tr>
<td valign="top" align="right" nowrap>
Fraternal:
</td>
<td valign="top" align="left">
<input type="text" name="frat" value="<?php echo $row["frat"]?>" size="20"></td>
</tr>
<? }
}
?>
</table>
</center>
</form>

storing the values into the cookie and displaying those values on page load

hi i have an php form which contains many fields, now i tried to write the code for storing all those values into an array and store them in a cookie in javascript. the code is as follows :
<script type="text/javascript">
function setDate()
{
var today = new Date();
var month = today.getMonth() + 1;
var day = today.getDate();
var year = today.getFullYear();
document.forms['form1'].elements['date'].value= month + "/" + day + "/" + year;
}
function add_newoption(optionname)
{
document.getElementById(optionname).InnerHTML = "";
}
var win = null;
function optionWindow(mypage,myname,w,h){
LeftPosition = (screen.width) ? (screen.width-w)/2: 0;
TopPosition = (screen.height) ? (screen.height-h)/2: 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition;
win = window.open(mypage,myname,settings);
win.focus();
}
function setAction(act)
{
document.forms['form1'].action = act;
document.forms['form1'].submit();
}
</script>
and the code for the form is as follows:
<body onLoad="setDate();">
<br/>
<center>
<fieldset class="style1" style="width:800px; background-color:#FFFFFF">
<h4 align="center"> Designer Form </h4>
<form id="form1" name="form1" method="post" >
<table width="700" border="0" cellpadding="2" cellspacing="2" bgcolor="#FFFFFF" style="text-align:left; padding: 25px 0px 25px 0px;">
<tr>
<td width="174" align="right">Date:</td>
<td width="331"><input name="date" type="text" size="10" readonly/></td>
<td width="175" style="text-align:center;">Order Number:
<input name="order_num" type="text" size="10" value=""/></td>
</tr>
<tr>
<td > </td>
<td> </td>
<td style="text-align:center;"><input name="orderdetails" type="submit" value="Get Order Details" onClick="setAction('?action=getorder');"/></td>
</tr>
<tr>
<td colspan='4'> <input name="email" id="email" type="hidden" value=""/> </td>
</tr>
<tr>
<td align="right">First Name:</td>
<td><input name="fname" type="text" value=""/></td>
<td> </td>
</tr>
<tr>
<td align="right">Last Name:</td>
<td><input name="lname" type="text" value=""/></td>
<td> </td>
</tr>
<tr>
<td align="right">Image Submitted:</td>
<td><input name="image" type="text" /></td>
<td> </td>
</tr>
<tr>
<td align="right">General Comments: </td>
<td><textarea name="gen_comments" cols="50" rows="6"></textarea></td>
<td> </td>
</tr>
<tr>
<td align="right">Internal Comments:</td>
<td><textarea name="int_comments" cols="50" rows="6"></textarea></td>
<td> </td>
</tr>
<tr>
<td align="right">Quality of the File:</td>
<td colspan="2" style="padding-right:4px">
<select name="quality">
<option>Select One</option><option value="good">Good</option><option value="ok">A bit low but we can use it</option><option value="low">Low. We are concerned it might effect the qaulity of the final</option><option value="not good">Not good. We cannot work with it</option><option value="test2">test2</option><option value="test">test</option><option value="lisa">Lisa1</option><option value="bbb">aaa</option> <!--option value="good">Good</option>
<option value="ok">A bit low but we can use it</option>
<option value="low">Low. We are concerned it might effect the qaulity of the final </option>
<option value="not good">Not good. We can't work with it</option-->
</select>
now what i want to do here is to get all these values entered in the form to store into an array and have to set cookie to retrieve them when the page re-loads...
how can i write a function for that using javascript and where to call that function in the form for getting those values into the form on page reloads..??
Any help will be needful to me....thanks in advance..
well i think you should use localStorage.setItem("DataKey","DataValue"); for store any value.
and for getting value you can use localStorage.getItem("DataKey");
FF,chrome,safari are support localStorage but i dont know about IE.

Categories