I keep getting errors while trying to validate this code.
Error message examples:
e.g. 1 - Line 152, Column 42: Unescaped '<' not allowed in attributes values …>
<input type="text" name="Name" value="<?php echo htmlspecialchars($Name); ?>"…
e.g. 2 - Line 152, Column 42: attributes construct error …>
<input type="text" name="Name" value="<?php echo htmlspecialchars($Name); ?>"…
e.g. 3 - Line 152, Column 42: Couldn't find end of Start Tag input line 152 …>
<input type="text" name="Name" value="<?php echo htmlspecialchars($Name); ?>"…
The same errors occur for any lines that contains the line e.g < php echo htmlspecialchars($...)
Please let me know what I am doing wrong.
<!-- Form-->
<form name="editcontact" method="post" action="">
<table border="1" cellpadding="2">
<caption>Edit Contact</caption>
<!--ID Input-->
<tr><td><?php if ($ContactID != '') { ?>
<input type="hidden" name="ContactID" value="<?php echo htmlspecialchars($ContactID); ?>" />
<?php } ?></td></tr>
<!--Name Input-->
<tr>
<td><label for="Name">Name</label></td>
<td><input type="text" name="Name" value="<?php echo htmlspecialchars($Name); ?>" size="30" maxlength="50" tabindex="1"/></td>
</tr>
<!-- Address Input-->
<tr>
<td><label for="Address">Address</label></td>
<td><textarea name="Address" cols="45" rows="5" tabindex="2"><?php echo htmlspecialchars($Address); ?> </textarea></td>
</tr>
<!--Phone Input-->
<tr>
<td><label for="Phone">Phone</label></td>
<td><input type="text" name="Phone" value="<?php echo htmlspecialchars($Phone); ?>" size="20" maxlength="20" tabindex="3" /> </td>
</tr>
<!--Mobile Input-->
<tr>
<td><label for="Mobile">Mobile</label></td>
<td><input type="text" name="Mobile" value="<?php echo htmlspecialchars($Mobile); ?>" size="20" maxlength="20" tabindex="4" /> </td>
</tr>
<!--Email Input-->
<tr>
<td><label for="Email">Email</label></td>
<td><input type="text" name="Email" value= "<?php echo htmlspecialchars($Email); ?>" size="30" maxlength="50" tabindex="5" /></td>
</tr>
<!--Submit Button-->
<tr>
<td colspan="2" align="center"><input type="submit" name="Submit" value="Submit" onclick="return validateForm()" tabindex="6"/>
</td>
</tr>
</table>
</form>
Run the PHP and validate the HTML output. Don't try to validate PHP as if it was HTML.
Related
I'm trying to add a new row into a HTML form by clicking on add new. I got some error. And also looking for delete row if clicked mistakenly on add new.
<table id='myTable'>
<tr>
<th>Proposer</th>
<th>Institution</th>
<th>E-mail</th>
<th>You will be present <br>(Y/N)</th></tr>
<tr>
<td><input type="text" name="proposer" size="20"><span
class="text-danger"><?php echo $proposerError; ?></span> </td>
<td><input type="text" name="institute" size="30"><span
class="text-danger"><?php echo $instituteError; ?></span> </td>
<td> <input type="text" name="email" size="15"> <span
class="text-danger"><?php echo $emailError; ?></span> </td>
<td><input type="text" name="present" size="4"><span
class="text-danger"><?php echo $presentError; ?></span></td>
</tr>
<a href=" onclick='$("<tr><td><input type="text" name="proposer2" size="20" /></td>
<td><input type="text" name="intitute2" size="30"/></td>
<td><input type="text" name="email2" size="15"/></td>
<td><input type="text" name="present2" size="4"/></td>
</tr>").appendTo($("myTable")); return false;'>Add new</a>
</table>
At first replace your html markup with this
<table id='myTable'>
<tr>
<th>Proposer</th>
<th>Institution</th>
<th>E-mail</th>
<th>You will be present <br>(Y/N)</th></tr>
<tr>
<td><input type="text" name="proposer" size="20"><span
class="text-danger"><?php echo $proposerError; ?></span> </td>
<td><input type="text" name="institute" size="30"><span
class="text-danger"><?php echo $instituteError; ?></span> </td>
<td> <input type="text" name="email" size="15"> <span
class="text-danger"><?php echo $emailError; ?></span> </td>
<td><input type="text" name="present" size="4"><span
class="text-danger"><?php echo $presentError; ?></span></td>
</tr>
</table>
Add More
Then Use this bellow jQuery code
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.add-more').click(function(event){
event.preventDefault();
jQuery('#myTable').append('<tr><td><input type="text" name="proposer2" size="20" /></td><td><input type="text" name="intitute2" size="30"/></td><td><input type="text" name="email2" size="15"/></td><td><input type="text" name="present2" size="4"/></td></tr>');
});
});
</script>
Then let me know the result.
Thanks
I am using HMVC Codeigniter pattern for my project. And In my project I need to set the value on form where input type of field is file.So, I feel greatful for them who help me to solve out this problem.
My associate controller is apply.php
<?php
class Career extends Controller{
function __construct(){
parent::__construct();
$this->load->Model('career_model','',TRUE);
$this->load->model('welcome/Mwelcome','',TRUE);
//session_start();
}
finction index(){
redirect('career/apply');
}
function apply(){
$this->load->library('form_validation');
$this->load->helper('url');
$this->form_validation->set_rules('fname','First Name','required|trim');
$this->form_validation->set_rules('mname','Middle Name','required|trim');
$this->form_validation->set_rules('lname','Last Name','required|trim');
$this->form_validation->set_rules('date','Date','required|trim');
$this->form_validation->set_rules('pAddress','Permanent Address','required|trim');
$this->form_validation->set_rules('cAddress','Contact Address','required|trim');
$this->form_validation->set_rules('gender','Gender','required|trim');
if (empty($_FILES['cv']['name']))
{
$this->form_validation->set_rules('cv', 'Attach Your CV', 'required');
}
if($this->form_validation->run($this)){
$_SESSION['msg']="Your form has been submitted succesfully!!";
redirect('career/apply');
}
else
{
$_SESSION['err']="Opp! There was some wrong to fill up a form so try again!!!";
redirect('career/apply');
}
}
$data=array('body'=>'apply');
$data['pgtitle']='Apply';
$this->load->view('temp',$data);
}
}
My associate view file is apply.php
<form action="<?php echo site_url()?>career/apply" method="post" enctype="multipart/form-data" onsubmit="return confirm('Do you really want to submit the form?');">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="">Name</td>
<td width="158"><label for="fname"></label>
<input type="text" name="fname" id="fname" placeholder="First Name" class='input-row' value="<?php echo set_value('fname')?>"/><span class="required"><?php echo form_error('fname');?></span></td>
<td width="158"><label for="mname"></label>
<input type="text" name="mname" id="mname" placeholder="Middle Name" class='input-row' value="<?php echo set_value('mname')?>"/></td>
<td width="158"><label for="lname"></label>
<input type="text" name="lname" id="lname" placeholder="Last Name" class='input-row' value="<?php echo set_value('lname')?>"/><span class="required"><?php echo form_error('lname');?></span></td>
</tr>
<tr>
<td>Date of Birth</td>
<td width="158"><label for="date"></label>
<input type="text" name="date" id="date" class='input-row' value="<?php echo set_value('date')?>" placeholder="yyyy-mm-dd"/><span class="required"><?php echo form_error('date');?></span></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Gender</td>
<td><div class="customSel">
<label>
<select name="gender" id="select" class='input-row' value="">
<option value="Female"<?php echo set_select('gender', 'Female', TRUE); ?>>Female</option>
<option value="Male"<?php echo set_select('gender', 'Male', TRUE); ?>>Male</option>
<option value="Please Selection"<?php echo set_select('gender', 'Please Selection', TRUE); ?>>Please Selection</option>
<?php /*?><option value="Other"<?php echo set_select('gender', 'Other', TRUE); ?>>Other</option><?php */?>
</select></label></div><span class="error"><?php echo form_error('gender')?></span></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Address</td>
<td><label for="pAddress"></label>
<input type="text" name="pAddress" id="pAddress" placeholder="Permanent Address" class='input-row' value="<?php echo set_value('pAddress')?>"/><span class="required"><?php echo form_error('pAddress');?></span></td>
<td><label for="cAddress"></label>
<input type="text" name="cAddress" id="cAddress" placeholder="Contact Address" value="<?php echo set_value('cAddress')?>"/><span class="required"><?php echo form_error('cAddress');?></span></td>
<td> </td>
</tr>
<tr>
<td>Attach Your CV</td>
<td colspan="2"><label for="cv"></label>
<input type="file" name="cv" id="cv" value="<?php echo set_value('cv')?>"/><span class="error"><?php echo form_error('cv')?></span></td>
</tr>
<tr>
<td><input type="submit" name="submit" id="submit" value="Submit" class="Button" />
<input type="reset" name="reset" id="reset" value="Reset" class="Button" /></td>
<td> </td>
<td> </td>
</tr>
</table>
</form >
I had tried to insert bulk data with same name field contains multiple rows. But only single row is inserted.
How to insert bulk data as different values to insert into the database.
INSERT INTO table_name (username, luck_number, test, tester) VALUES (('$username', '$luck_number', '$test', '$tester').
<tr>
<td>1</td>
<input type="hidden" name="username" value="<?php echo $login_session; ?>" />
<td>
<input type="text" name="luck_number" value="" />
</td>
<td>
<input type="text" name="big" value="" />
</td>
<td>
<input type="text" name="test" value="" />
</td>
<td>
<input type="text" name="tester" value="" />
</td>
</tr>
<tr>
<td>2</td>
<input type="hidden" name="username" value="<?php echo $login_session; ?>" />
<td>
<input type="text" name="luck_number" value="" />
</td>
<td>
<input type="text" name="big" value="" />
</td>
<td>
<input type="text" name="test" value="" />
</td>
<td>
<input type="text" name="tester" value="" />
</td>
</tr>
<tr>
<td>3</td>
<input type="hidden" name="username" value="<?php echo $login_session; ?>" />
<td>
<input type="text" name="luck_number" value="" />
</td>
<td>
<input type="text" name="big" value="" />
</td>
<td>
<input type="text" name="test" value="" />
</td>
<td>
<input type="text" name="tester" value="" />
</td>
</tr>
#nisha,In your scenario only single row is inserted because variables are same name so it's overridden, Please try below code, It will give you array of fields so you can easily create for-loop & do multiple insert with your query.
<form method="post" name="userdata">
<tr>
<td>1</td>
<input type="hidden" name="username[]" value="<?php echo $login_session; ?>" />
<td>
<input type="text" name="luck_number[]" value="" />
</td>
<td>
<input type="text" name="big[]" value="" />
</td>
<td>
<input type="text" name="test[]" value="" />
</td>
<td>
<input type="text" name="tester[]" value="" />
</td>
</tr>
<tr>
<td>2</td>
<input type="hidden" name="username[]" value="<?php echo $login_session; ?>" />
<td>
<input type="text" name="luck_number[]" value="" />
</td>
<td>
<input type="text" name="big[]" value="" />
</td>
<td>
<input type="text" name="test[]" value="" />
</td>
<td>
<input type="text" name="tester[]" value="" />
</td>
</tr>
<tr>
<td>3</td>
<input type="hidden" name="username[]" value="<?php echo $login_session; ?>" />
<td>
<input type="text" name="luck_number[]" value="" />
</td>
<td>
<input type="text" name="big[]" value="" />
</td>
<td>
<input type="text" name="test[]" value="" />
</td>
<td>
<input type="text" name="tester[]" value="" />
</td>
</tr>
<input type="submit" name="submit">
</form>
**Note:**you can worry about the security issue letter. read the answer with the comment.
Store them in array by adding [ ] this in your input field
<tr>
<td>1</td>
<form action="" method="POST">
<input type="hidden" name="username" value="<?php echo $login_session; ?>"/>
<td><input type="text" name="luck_number[]" value=""/></td>
<td><input type="text" name="big[]" value=""/></td>
<td><input type="text" name="test[]" value=""/></td>
<td><input type="text" name="tester[]" value=""/></td>
</tr>
<tr>
<td>2</td>
<input type="hidden" name="username" value="<?php echo $login_session; ?>"/>
<td><input type="text" name="luck_number[]" value=""/></td>
<td><input type="text" name="big[]" value=""/></td>
<td><input type="text" name="test[]" value=""/></td>
<td><input type="text" name="tester[]" value=""/></td>
</tr>
<tr>
<td>3</td>
<input type="hidden" name="username" value="<?php echo $login_session; ?>"/>
<td><input type="text" name="luck_number[]" value=""/></td>
<td><input type="text" name="big[]" value=""/></td>
<td><input type="text" name="test[]" value=""/></td>
<td><input type="text" name="tester[]" value=""/></td>
</tr>
<tr></td><input type="submit" name="submit" value="submit"/><tr></td>
</form>
<?php
//connect with your database
for($i=0;$i<count($_POST['luck_number']);$i++)
{
//set the value for variable
$luck_number=$_POST['luck_number'][$i];
$test=$_POST['test'][$i];
$tester=$_POST['tester'][$i];
//run your query
//INSERT INTO table_name (username, luck_number, test, tester) VALUES (('$username', '$luck_number', '$test', '$tester').
}
First of all change all field names by adding [] at the end.
Second step, to parsing all values you may use something like this
for($i=0; $i < $count($_GET['username']); $i++)
{
$username = $_GET['username'][$i];
$luck_number= $_GET['luck_number'][$i];
$big= $_GET['big'][$i];
$test= $_GET['test'][$i];
$tester= $_GET['tester'][$i];
// insert into database
}
The reason of inserting single row instead of multiple rows is your input field name. You are using same name in different input field so when the server gets the reply it replace the duplicate name and the last occurrence is outputted.
The thing you have to do is to use array. If you use known number of rows then you can simply use a for loop to insert data.
<tr>
<td>1</td>
<input type="hidden" name="username[]" value="<?php echo $login_session; ?>" />
<td>
<input type="text" name="luck_number[]" value="" />
</td>
<td>
<input type="text" name="big[]" value="" />
</td>
<td>
<input type="text" name="test[]" value="" />
</td>
<td>
<input type="text" name="tester[]" value="" />
</td>
</tr>
<tr>
<td>2</td>
<input type="hidden" name="username[]" value="<?php echo $login_session; ?>" />
<td>
<input type="text" name="luck_number[]" value="" />
</td>
<td>
<input type="text" name="big[]" value="" />
</td>
<td>
<input type="text" name="test[]" value="" />
</td>
<td>
<input type="text" name="tester[]" value="" />
</td>
</tr>
<tr>
<td>3</td>
<input type="hidden" name="username[]" value="<?php echo $login_session; ?>" />
<td>
<input type="text" name="luck_number[]" value="" />
</td>
<td>
<input type="text" name="big[]" value="" />
</td>
<td>
<input type="text" name="test[]" value="" />
</td>
<td>
<input type="text" name="tester[]" value="" />
</td>
</tr>
<?php
for ($i=0; $i<count($_POST['username']); $i++)
{
mysql_query("INSERT INTO table_name (`username`, `luck_number`, `test`, `tester`) VALUES (('".$_POST['username'][$i]."', '".$_POST['luck_number'][$i]."', '".$_POST['test'][$i]."', '".$_POST['tester'][$i]."')");
}
?>
Note: Sanitizing variable is always been a good practice and strongly recommended.
I have recently created a contact form with PHP mailer which is finally working. However the success message is breaking my page and displaying in the top left corner instead of underneath the form. As you can see below.
This is the HTML:
<form method="POST">
<table border="1">
<tr>
<td><label for="name" class="g">Name</label></td>
<td><input id="name" name="name" type="text" autofocus></td>
</tr>
<tr>
<td><label for="address" class="g">Address</label></td>
<td><textarea rows="3" id="address" name="address" cols="50"></textarea></td>
</tr>
<tr>
<td><label for="number" class="g">Contact number</label></td>
<td><input id="number" name="number" type="text" autofocus></td>
</tr>
<tr>
<td><label for="email" class="g">Email</label></td>
<td><input id="email" name="email" type="text" placeholder="example#domain.com" autofocus></td>
</tr>
<tr>
<td><label for="message" class="g">Enquiry</label></td>
<td><textarea rows="3" id="message" name="message" cols="50"></textarea></td>
</tr>
</table>
<input type="submit" value="Submit" name="submit">
<?php
if ($success) {
echo $success;
}
?>
</form>
It also creates a huge blank white area in the middle of my page under the form. Does anyone know why this is? or how I would go about debugging it?
You should put this in a div or a span
<div style="text-align:center;"> <?php
if ($success) {
echo $success;
}
?>
</div>
Try following code:
<form method="POST">
<table border="1">
<tr>
<td><label for="name" class="g">Name</label></td>
<td><input id="name" name="name" type="text" autofocus></td>
</tr>
<tr>
<td><label for="address" class="g">Address</label></td>
<td><textarea rows="3" id="address" name="address" cols="50"></textarea></td>
</tr>
<tr>
<td><label for="number" class="g">Contact number</label></td>
<td><input id="number" name="number" type="text" autofocus></td>
</tr>
<tr>
<td><label for="email" class="g">Email</label></td>
<td><input id="email" name="email" type="text" placeholder="example#domain.com" autofocus></td>
</tr>
<tr>
<td><label for="message" class="g">Enquiry</label></td>
<td><textarea rows="3" id="message" name="message" cols="50"></textarea></td>
</tr>
<?php
if ($success) {?>
<tr><td colspan="2">
<?php echo $success; ?>
</td></tr>
<?php }
?>
</table>
<input type="submit" value="Submit" name="submit">
</form>
I have a form that I have created for internal use. I have been able to populate the MySQL database with the data from the form. I have also created a search function that will pull the data back into the fields based on an ID key (in this case a number). All of the text fields come back into the fields, but the Text Area data does not. I go to the MySQL database, and the table fields for those Text Areas are filled in, but they don't seem to pull back into the form. Please help me if you can. Thank you.
My HTML form:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>- - = = EPC Print Order Form = = - - </title>
</head>
<body bgcolor="#DFDFD9">
<h1>Digital Print Form    <input type="image" src="http://commonmedia.asicentral.com/180000/182101/EPC_KAPP.jpg"></h1>
<!-- form to get key detail of record in database -->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Request RFQ</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><form name="form" method="POST" action="form1.php">
RFQ#:</td><td><input type="text" name="search"></td><td><input type="submit" value="submit"></td>
</form></tr></table>
</fieldset>
<!--------------------- Print Form Data ------------------>
<form action="mysqlTest.php" method="post" id="prayfrm" name="prayfrm" onsubmit="return checkform(this);" onreset="return confirm('Do you want to clear this form?')">
<input type="hidden" name="drfq" value="6">
<!--********** Basic Job Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Job Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="drepid">Sales Rep</label></td>
<td><input type="text" name="drepid" size="30" required="true"/>
</td>
<td><label>Today's Date</label></td>
<td><input type="text" name="datepicker" size="10"/></td>
</tr>
<tr>
<td><label for="repemail">Rep Email</label></td>
<td><input id="repemail" name="repemail" type="text" size="30" required="true" /></td>
<td><label>Date Needed</label></td>
<td><input id="dateneeded" name="dateneeded" type="text" size="10" required="true" /> </td>
</tr>
<tr>
<td><label for="description">Description</label></td>
<td><input id="description" name="description" type="text" size="30" required="true" /></td>
<td><label for="qty">Quantity</label></td>
<td><input id="qty" name="qty" type="text" size="10" required="true" /></td>
</tr>
<tr>
<td><label for="pgsizeh">Page Size (h) x (w)</label></td>
<td><input id="pgsizeh" name="pgsizeh" type="text" size="10" required="true" /> x <input id="pgsizew" name="pgsizew" type="text" size="13" required="true" /></td>
<td><label for="pageno">Page Number</label></td>
<td><input id="pageno" name="pageno" type="text" size="10" required="true" /></td>
</tr>
<tr>
<td><label for="stock">Stock</label></td>
<td><input id="stock" name="stock" type="text" size="10" required="true" />  <label for="stock">Color   </label>
<input type="text" name="ink" size="6" required="true"/>
</td>
<td><label for="inknote">   Explain </label></td>
<td><input id="inknote" name="inknote" type="text" size="10" /></td>
</tr>
<tr>
<td><label for="rfq">Referenced RFQ:</label></td>
<td><input id="rfq" name="rfq" type="text" size="10" required="true" /><td><label for="finishing">Finishing</label></td>
<td><input id="finishing" name="finishing" type="text" size="10" required="true" />
</tr>
</table></fieldset>
<!--********** Customer Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Customer Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="dfirstname">First Name</label></td><td><input id="dfirstname" name="dfirstname" type="text" size="31" required="true" /></td><td><label for="dlastname">  Last </label></td><td><input id="dlastname" name="dlastname" type="text" size="31" required="true" /></td>
</tr>
<tr>
<td><label for="dorganization">Organization</label></td>
<td><input id="dorganization" name="dorganization" type="text" size="31" required="true" /></td><td><label for="email">Email</label></td>
<td><input id="email" name="email" type="text" size="31" required="true" /></td>
</tr>
<tr>
<td><label for="daddress1">Address</label></td><td><input id="daddress1" name="daddress1" type="text" size="31" required="true" /><td></td><td><input id="daddress2" name="daddress2" type="text" size="31" />
</tr>
<tr>
<td><label for="dcity">City</label></td><td><input id="dcity" name="dcity" type="text" size="25" required="true" /> <label for="dstate"> State</label></td><td><input id="dstate" name="dstate" type="text" size="3" required="true" /> <td><label for="dzip"> Zip </label> <input id="dzip" name="dzip" type="text" size="27" required="true" /></tr>
<tr>
<td><label for="phone">Phone </label><td><input id="phone" name="phone" type="text" size="31" required="true" /></td><td><label for="fax">Fax </label><td><input id="fax" name="fax" type="text" size="31" required="true" /> </td>
</tr></table></fieldset>
<!--********** Delivery Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Delivery Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="proof">Proof?</label>  <input type="checkbox" name="proof" value="yes" required="true" />  </td><td><label for="whoproof">Proof to Whom?</label> <input id="whoproof" name="whoproof" type="text" size="44" required="true" /></td>
</tr>
<tr>
<td><label for="quote">Quote?</label> <input type="checkbox" name="quote" value="yes" required="true" />  </td>
<td><label for="amount">Amount: $</label> <input id="amount" name="amount" type="text" size="50" required="true" /></td>
</tr>
<tr>
<td><label for="delivery">Delivery Instructions</label></td><td><textarea name="delivery" rows="4" cols="50"></textarea></tr>
<tr>
<td><label for="notes">Additional Notes</label></td><td><textarea name="notes" rows="4" cols="50"></textarea>
</tr>
<td align="right"><input name="submit" type="submit" id="submit" value="Submit" /></td>
<td align="left"><input name="Reset" type="reset" id="reset" value="Reset Form" /></table></fieldset>
</body>
</html>
My PHP File for adding fields to database
<?php
$dbhost = 'hostname';
$dbuser = 'username';
$dbpass = '*******';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'dbasename';
mysql_select_db($dbname);
// -------------------------------------------------------------------
// Field Names
// -------------------------------------------------------------------
$drepid=mysql_real_escape_string($_POST['drepid']);
$datepicker=mysql_real_escape_string($_POST['datepicker']);
$repemail=mysql_real_escape_string($_POST['repemail']);
$dateneeded=mysql_real_escape_string($_POST['dateneeded']);
$description=mysql_real_escape_string($_POST['description']);
$qty=mysql_real_escape_string($_POST['qty']);
$pgsizeh=mysql_real_escape_string($_POST['pgsizeh']);
$pgsizew=mysql_real_escape_string($_POST['pgsizew']);
$pageno=mysql_real_escape_string($_POST['pageno']);
$stock=mysql_real_escape_string($_POST['stock']);
$ink=mysql_real_escape_string($_POST['ink']);
$inknote=mysql_real_escape_string($_POST['inknote']);
$rfq=mysql_real_escape_string($_POST['rfq']);
$finishing=mysql_real_escape_string($_POST['finishing']);
$dfirstname=mysql_real_escape_string($_POST['dfirstname']);
$dlastname=mysql_real_escape_string($_POST['dlastname']);
$dorganization=mysql_real_escape_string($_POST['dorganization']);
$email=mysql_real_escape_string($_POST['email']);
$daddress1=mysql_real_escape_string($_POST['daddress1']);
$daddress2=mysql_real_escape_string($_POST['daddress2']);
$dcity=mysql_real_escape_string($_POST['dcity']);
$dstate=mysql_real_escape_string($_POST['dstate']);
$dzip=mysql_real_escape_string($_POST['dzip']);
$phone=mysql_real_escape_string($_POST['phone']);
$fax=mysql_real_escape_string($_POST['fax']);
$proof=mysql_real_escape_string($_POST['proof']);
$whoproof=mysql_real_escape_string($_POST['whoproof']);
$quote=mysql_real_escape_string($_POST['quote']);
$amount=mysql_real_escape_string($_POST['amount']);
$delivery=mysql_real_escape_string($_POST['delivery']);
$notes=mysql_real_escape_string($_POST['notes']);
$sql = "INSERT INTO epc_print (drepid, datepicker, repemail, dateneeded, description, qty, pgsizeh, pgsizew, pageno, stock, ink, inknote, rfq, finishing, dfirstname, dlastname, dorganization, email, daddress1, daddress2, dcity, dstate, dzip, phone, fax, proof, whoproof, quote, amount, delivery, notes) values ('$drepid', '$datepicker', '$repemail', '$dateneeded', '$description', '$qty', '$pgsizeh', '$pgsizew', '$pageno', '$stock', '$ink', '$inknote', 'rfq', '$finishing', '$dfirstname', '$dlastname', '$dorganization', '$email', '$daddress1', '$daddress2', '$dcity', '$dstate', '$dzip', '$phone', '$fax', '$proof', '$whoproof', '$quote', '$amount', '$delivery', '$notes')";
mysql_query($sql) or die(mysql_error());
echo "
<code><pre></code>";
echo "POST:";
print_r($_POST);
echo "<code></pre></code>
";
echo "1 record added";
?>
Then my php file to retrieve data:
<?php
$connection = mysql_connect('hostname','username','*****') or die ("Couldn't connect to server.");
$db = mysql_select_db('databasename', $connection) or die ("Couldn't select database.");
$search=$_POST['search'];
$data = 'SELECT * FROM `epc_print` WHERE `drfq` = "'.$search.'"';
$query = mysql_query($data) or die("Couldn't execute query. ". mysql_error());
$data2 = mysql_fetch_array($query);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>- - = = EPC Print Form = = - - </title>
</head>
<body bgcolor="#DFDFD9">
<h1>Digital Print Form    <input type="image" src="http://commonmedia.asicentral.com/180000/182101/EPC_KAPP.jpg"></h1>
<!-- form to get key detail of record in database -->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Request RFQ</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><form name="form" method="POST" action="form1.php">
RFQ#:</td><td><input type="text" name="search"></td><td><input type="submit" value="submit"></td>
</form></tr></table>
</fieldset>
<!--------------------- Print Form Data ------------------>
<form action="form2.php" method="post" id="prayfrm" name="prayfrm" onsubmit="return checkform(this);" onreset="return confirm('Do you want to clear this form?')">
<input type="hidden" name="drfq" value="6">
<!--********** Basic Job Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Job Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="drepid">Sales Rep</label></td>
<td><input id="drepid" name="drepid" type="text" size="30" value="<?php echo htmlspecialchars ($data2[drepid])?>" required="true" /></td>
</td>
<td><label>Today's Date</label></td>
<td><input id="datepicker" name="datepicker" type="text" size="10" value="<?php echo htmlspecialchars ($data2[datepicker])?>" required="true" /></td>
</tr>
<tr>
<td><label for="repemail">Rep Email</label></td>
<td><input id="repemail" name="repemail" type="text" size="30" value="<?php echo htmlspecialchars ($data2[repemail])?>" required="true" /></td>
<td><label>Date Needed</label></td>
<td><input id="dateneeded" name="dateneeded" type="text" size="10" value="<?php echo htmlspecialchars ($data2[dateneeded])?>" required="true" /></td></td>
</tr>
<tr>
<td><label for="description">Description</label></td>
<td><input id="description" name="description" type="text" size="30" value="<?php echo htmlspecialchars ($data2[description])?>" required="true" /></td>
<td><label for="qty">Quantity</label></td>
<td><input id="qty" name="qty" type="text" size="10" value="<?php echo htmlspecialchars ($data2[qty])?>"required="true" /></td>
</tr>
<tr>
<td><label for="pgsizeh">Page Size (h) x (w)</label></td>
<td><input id="pgsizeh" name="pgsizeh" type="text" size="10" value="<?php echo htmlspecialchars ($data2[pgsizeh])?>" required="true" /> x <input id="pgsizew" name="pgsizew" type="text" size="14" value="<?php echo htmlspecialchars ($data2[pgsizew])?>" required="true" /></td>
<td><label for="pageno">Page Number</label></td>
<td><input id="pageno" name="pageno" type="text" size="10" value="<?php echo htmlspecialchars ($data2[pageno])?>" required="true" /></td>
</tr>
<tr>
<td><label for="stock">Stock</label></td>
<td><input id="stock" name="stock" type="text" size="10" value="<?php echo htmlspecialchars ($data2[stock])?>" required="true" /> <label for="ink">Color </label> <input id="ink" name="ink" type="text" size="10" value="<?php echo htmlspecialchars ($data2[ink])?>" required="true" /></td>
<td><label for="inknote">   Explain </label></td>
<td><input id="inknote" name="inknote" type="text" size="10" value="<?php echo htmlspecialchars ($data2[inknote])?>"/></td>
</tr>
<tr>
<td><label for="rfq">Referenced RFQ:</label></td>
<td><input id="rfq" name="rfq" type="text" size="10" value="<?php echo htmlspecialchars ($data2[rfq])?>" required="true"/></td> <td><label for="finishing">Finishing</label></td>
<td><input id="finishing" name="finishing" type="text" size="10" value= "<?php echo htmlspecialchars ($data2[finishing])?>" required="true" />
</tr>
</table></fieldset>
<!--********** Customer Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Customer Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="dfirstname">First Name</label></td><td><input id="dfirstname" name="dfirstname" type="text" size="31" value="<?php echo htmlspecialchars ($data2[dfirstname])?>" required="true" /></td><td><label for="dlastname">  Last </label></td><td><input id="dlastname" name="dlastname" type="text" size="31" value= "<?php echo htmlspecialchars ($data2[dlastname])?>"required="true" /></td>
</tr>
<tr>
<td><label for="dorganization">Organization</label></td>
<td><input id="dorganization" name="dorganization" type="text" size="31" value="<?php echo htmlspecialchars ($data2[dorganization])?>" required="true" /></td><td><label for="email">Email</label></td>
<td><input id="email" name="email" type="text" size="31" value="<?php echo htmlspecialchars ($data2[email])?>" required="true" /></td>
</tr>
<tr>
<td><label for="daddress1">Address</label></td><td><input id="daddress1" name="daddress1" type="text" size="31" value="<?php echo htmlspecialchars ($data2[daddress1])?>" required="true" /><td></td><td><input id="daddress2" name="daddress2" type="text" size="31" value="<?php echo htmlspecialchars ($data2[daddress2])?>"/>
</tr>
<tr>
<td><label for="dcity">City</label></td><td><input id="dcity" name="dcity" type="text" size="25" value="<?php echo htmlspecialchars ($data2[dcity])?>" required="true" /> <label for="dstate"> State</label></td><td><input id="dstate" name="dstate" type="text" size="3" value="<?php echo htmlspecialchars ($data2[dstate])?>" required="true" /> <td><label for="dzip"> Zip </label> <input id="dzip" name="dzip" type="text" size="27" value="<?php echo htmlspecialchars ($data2[dzip])?>" required="true" /></tr>
<tr>
<td><label for="phone">Phone </label><td><input id="phone" name="phone" type="text" size="31" value="<?php echo htmlspecialchars ($data2[phone])?>" required="true" /></td><td><label for="fax">Fax </label><td><input id="fax" name="fax" type="text" size="31" value="<?php echo htmlspecialchars ($data2[fax])?>"/> </td>
</tr></table></fieldset>
<!--********** Delivery Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Delivery Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="proof">Proof?</label>  <input type="checkbox" name="proof" value="<?php echo ($data2[proof])?>" />  </td><td><label for="whoproof">Proof to Whom?</label> <input id="whoproof" name="whoproof" type="text" size="44" value="<?php echo htmlspecialchars ($data2[whoproof])?>"required="true" /></td>
</tr>
<tr>
<td><label for="quote">Quote?</label> <input type="checkbox" name="quote" value="<?php echo htmlspecialchars ($data2[quote])?>" required="true" />  </td>
<td><label for="amount">Amount: $</label> <input id="amount" name="amount" type="text" size="50" value="<?php echo htmlspecialchars ($data2[amount])?>" required="true" /></td>
</tr>
<tr>
<td><label for="delivery">Delivery Instructions</label></td><td><textarea name="delivery" rows="4" cols="50" value="<?php echo htmlspecialchars ($data2[delivery])?>" /></textarea></tr>
<tr>
<td><label for="notes">Additional Notes</label></td><td><textarea name="notes" rows="4" cols="50" value="<?php echo htmlspecialchars ($data2[notes])?>"/></textarea>
</tr>
<td align="right"><input name="submit" type="submit" id="submit" value="Submit" /></td>
<td align="left"><input name="Reset" type="reset" id="reset" value="Reset Form" /></table></fieldset>
</body>
</html>
The default value of a text area is provided by the text node inside the element, not a value attribute.
<textarea>Default value
Which can have new lines</textarea>
value isn't a valid attribute for textareas, you need to use <textarea>value</textarea>