Need assistance with following code. Value for "customer_id" is not posting after hitting submit for the first generated row only. the second and following work as intended.
Other pages use this same format for deleting, but do not redirect to another page like this one does. No issues with deleting.
<html>
<!-- the body section -->
<body>
<main>
<section>
<!-- display a table of customers -->
<h2>Results</h2>
<table>
<tr>
<th>Name</th>
<th>Email Address</th>
<th>City</th>
<th> </th>
</tr>
<?php foreach($customers as $cus) : ?>
<tr>
<td><?php echo $cus['firstName'].' '.$cus['lastName']; ?></td>
<td><?php echo $cus['email']; ?></td>
<td class="right"><?php echo $cus['city']; ?></td>
<td><form action="view_and_update.php" method="post" id="search">
<input type="text" name="customer_id" value="<?php echo $cus['customerID']; ?>">
<input name="submit" type="submit" value="Select">
<?php include "redirect.php";?>
</form></td>
</tr>
<?php endforeach; ?>
</table>
</section>
</main>
</body>
</html>
redirect.php looks like this:
<?php
if(isset($_POST["submit"])){
// To redirect form on a particular page
header("Location: view_and_update.php");
}
?>
Any assistance is greatly appreciated. This is for an assignment, and we are using the languages as specified with XAMPP/myphpadmin. No problem retrieving, editing, adding, or deleting data in any other circumstance. This is the only problem page.
By using the following example code I got the correct post to view_and_update.php
It has to be something else, it is not the code.
<?php $customers = [
['firstName' => 'Alice', 'lastName' => 'Al', 'email' => 'alison#domain.com', 'city' => 'MyCity', 'customerID' => 123],
['firstName' => 'Bob', 'lastName' => 'Bo', 'email' => 'bob#domain.com', 'city' => 'MyCity', 'customerID' => 124]
]; ?>
<html>
<!-- the body section -->
<body>
<main>
<section>
<!-- display a table of customers -->
<h2>Results</h2>
<table>
<tr>
<th>Name</th>
<th>Email Address</th>
<th>City</th>
<th> </th>
</tr>
<?php foreach($customers as $cus) : ?>
<tr>
<td><?php echo $cus['firstName'].' '.$cus['lastName']; ?></td>
<td><?php echo $cus['email']; ?></td>
<td class="right"><?php echo $cus['city']; ?></td>
<td><form action="view_and_update.php" method="post" id="search">
<input type="text" name="customer_id" value="<?php echo $cus['customerID']; ?>">
<input name="submit" type="submit" value="Select">
</form></td>
</tr>
<?php endforeach; ?>
</table>
</section>
</main>
</body>
</html>
Related
I am making the modification for the query and already add and everything but in modifying it does not work with 'id' that I put after putting the address of the modification page
this is the table
<!DOCTYPE html>
<html>
<head>
<title> TABLA </title>
</head>
<body>
<center>
<table bgcolor="#85C1E9" border="3">
<thead>
<tr>
<th colspan="1">Nuevo</th>
<th colspan="5">Lista de usuarios</th>
</tr>
</thead>
<tbody>
<tr>
<td>Id</td>
<td>Nombre</td>
<td>Apellido</td>
<td>Correo</td>
<td colspan="2"><center>Operaciones</center></td>
</tr>
<?php
include("conexiones.php");
$query="SELECT * FROM usuarios";
$resultado=$conexion->query($query);
while ($row=$resultado->fetch_assoc()) {
?>
<tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['nombre'];?></td>
<td><?php echo $row['apellido'];?></td>
<td><?php echo $row['correo'];?></td>
<td><a href="modificar.php?id=<?php echo $row['id'];
?>">Modificar</a></td>
<td><a href="eliminar.php?id=<?php echo $row['id']; ?
>">Eliminar</a></td>
</tr>
<?php
}
?>
</tbody>
</table>
</center>
</body>
</html>
here the modify page
<!DOCTYPE html>
<html>
<head>
<title>Guardar</title>
</head>
<body>
<center>
<form action="guardar.php" method="POST" name="guardar"><br><br><br>
<?php
$id=$_REQUEST['id'];
include("conexiones.php");
$query="SELECT * FROM usuarios";
$resultado=$conexion->query($query);
$row=$resultado->fetch_assoc();
?>
<input type="text" required="" name="nombre" placeholder="Nombre..."
value="<?php echo $row['nombre'];?>"><br><br>
<input type="text" required="" name="apellido"
placeholder="Apellido..." value="<?php echo $row['apellido'];?>">
<br><br>
<input type="text" required="" name="correo"
placeholder="Correo..." value="<?php echo $row['correo'];?>"><br>
<br>
<input type="submit" value="Aceptar">
</form>
</center>
</body>
</html>
the error is that when I press modify in the query I get like this:
http://localhost/modificar.php?id=%3C?echo%20$row[%27id%27];?%3E
and the way it should go (for example) is like this:
http://localhost/modificar.php?id=1
Try this:
<?php
include("conexiones.php");
$query="SELECT * FROM usuarios";
$resultado=$conexion->query($query);
?>
<?php while ($row=$resultado->fetch_assoc()): ?>
<tr>
<td><?= $row['id'] ?></td>
<td><?= $row['nombre'] ?></td>
<td><?= $row['apellido'] ?></td>
<td><?= $row['correo'] ?></td>
<td><a href="modificar.php?id=<?= $row['id'] ?>">
Modificar</a></td>
<td><a href="eliminar.php?id=<?= $row['id'] ?>">
Eliminar</a></td>
</tr>
<?php endwhile; ?>
hope it helps.
I am having two php files, one contains a form and another to display the content entered and save button. After confirming the details are correct he has to save and the data should be inserted into the table. I have given the code below
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script>
</head>
<body>
<?php
$roll=$_POST['roll'];
$sname=$_POST['sname'];
$fname=$_POST['fname'];
$gender=$_POST['gender'];
$aadhar=$_POST['aadhar'];
$caste=$_POST['caste'];
?>
<div class="container container-center">
<!-------------total panel------------------------------------>
<div class="panel-info">
<!------panel heading------>
<div class="panel-heading">
<h2><center><u>STUDENT DETAILS</u></center></h2>
</div> <!-panel heading->
<div class="panel-body">
<form method="post" action="">
<table align="center" border="0">
<tbody>
<tr>
<td rowspan="7"><?php echo"<img src=/photo/$roll.jpg width='200px' height='300px' id='photo'>"; ?></td>
<td>1. Roll Number & Photo:</td>
<td><?php echo"".strtoupper($roll).""; ?></td>
</tr>
<tr>
<td>2. Name of the Student:</td>
<td><?php echo"".strtoupper($sname).""; ?></td>
</tr>
<tr>
<td>3. Name of the Father:</td>
<td><?php echo"".strtoupper($fname).""; ?></td>
</tr>
<tr>
<td>4. Gender:</td>
<td><?php
if($gender=='M')
{ echo"Male";}
else
{echo"Female";}
?></td>
</tr>
<tr>
<td>5. Aadhar Number:</td>
<td><?php echo"$aadhar"; ?></td>
</tr>
<tr>
<td>6. Caste:</td>
<td><?php echo"$caste"; ?></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" id="submit" name="submit" class="btn btn-info" value="save"></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
<?php
if(isset($_POST['submit']))
{
echo"<script>alert('success')</script>";
}
?>
</body>
when i click the save button then only the data must be saved. but even if not click the save the php code in isset is executing.
the data obtained by $_POST is from the form.
Please help me.
NOTE:
Actually Problem is that, you don't get the data on this page.. in your POST request with given variable so that Please Just Check it . Other Code Is Fine. !! ( Here I am Just Pass Dummy Data ) Like Below.
$roll= '1234';
$sname='XYZ';
$fname= 'ABC';
$gender= 'M';
$aadhar= '123456789100';
$caste= 'A12345';
Solution: You Have To Get DATA Here in post request from your first_php_page form where user enter the details regarding given fields: roll,sname,fname,gender,aadhar,caste
After here in secound_php_page check that Submit button is set then store the values in varable Like below Code:
NOTE: At The End YoU Have To Write The Insert Query On Save Button Click. To Store The data in Database.
<?php
if(isset($_POST['Submit'])){
$roll=$_POST['roll'];
$sname=$_POST['sname'];
$fname=$_POST['fname'];
$gender=$_POST['gender'];
$aadhar=$_POST['aadhar'];
$caste=$_POST['caste'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script>
</head>
<body>
<?php
/*
$roll=$_POST['roll'];
$sname=$_POST['sname'];
$fname=$_POST['fname'];
$gender=$_POST['gender'];
$aadhar=$_POST['aadhar'];
$caste=$_POST['caste'];
*/
// SET THE DUMMY DATA FOR Result check
$roll= '1234';
$sname='XYZ';
$fname= 'ABC';
$gender= 'M';
$aadhar= '123456789100';
$caste= 'A12345';
?>
<div class="container container-center">
<!-- total panel -->
<div class="panel-info">
<!-- panel heading -->
<div class="panel-heading">
<h2><center><u>STUDENT DETAILS</u></center></h2>
</div>
<!--panel heading -->
<div class="panel-body">
<form method="post" action="">
<table align="center" border="0">
<tbody>
<tr>
<td rowspan="7"><?php echo"<img src=/photo/$roll.jpg width='200px' height='300px' id='photo'>"; ?></td>
<td>1. Roll Number & Photo:</td>
<td><?php echo"".strtoupper($roll).""; ?></td>
</tr>
<tr>
<td>2. Name of the Student:</td>
<td><?php echo"".strtoupper($sname).""; ?></td>
</tr>
<tr>
<td>3. Name of the Father:</td>
<td><?php echo"".strtoupper($fname).""; ?></td>
</tr>
<tr>
<td>4. Gender:</td>
<td><?php
if($gender=='M')
{ echo"Male";}
else
{echo"Female";}
?></td>
</tr>
<tr>
<td>5. Aadhar Number:</td>
<td><?php echo"$aadhar"; ?></td>
</tr>
<tr>
<td>6. Caste:</td>
<td><?php echo"$caste"; ?></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" id="submit" name="submit" class="btn btn-info" value="save"></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
<?php
if(isset($_POST['submit']))
{
echo"<script>alert('success')</script>";
}
?>
</body>
</HTML>
OUTPUT: DATA Display
AND ONCLICK SAVE
There are few issues with your code, such as:
There's no point having a form and save button(in another page) if you don't have input elements and don't send your data using $_POST superglobal. Create input elements for each of your fields with type="hidden", for example like this:
<td><?php echo strtoupper($roll); ?><input type="hidden" name="roll" value="<?php echo strtoupper($roll); ?>"></td>
Here's the full form code,
// your code
<form method="post" action="">
<table align="center" border="0">
<tbody>
<tr>
<td rowspan="7"><?php echo"<img src=/photo/$roll.jpg width='200px' height='300px' id='photo'>"; ?></td>
<td>1. Roll Number & Photo:</td>
<td><?php echo strtoupper($roll); ?><input type="hidden" name="roll" value="<?php echo strtoupper($roll); ?>"></td>
</tr>
<tr>
<td>2. Name of the Student:</td>
<td><?php echo strtoupper($sname); ?><input type="hidden" name="sname" value="<?php echo strtoupper($sname); ?>"></td>
</tr>
<tr>
<td>3. Name of the Father:</td>
<td><?php echo strtoupper($fname); ?><input type="hidden" name="fname" value="<?php echo strtoupper($fname); ?>"></td>
</tr>
<tr>
<td>4. Gender:</td>
<td>
<?php
if($gender=='M'){
echo"Male";
}else{
echo"Female";
}
?>
<input type="hidden" name="gender" value="<?php echo $gender; ?>">
</td>
</tr>
<tr>
<td>5. Aadhar Number:</td>
<td><?php echo $aadhar; ?><input type="hidden" name="aadhar" value="<?php echo $aadhar; ?>"></td>
</tr>
<tr>
<td>6. Caste:</td>
<td><?php echo $caste; ?><input type="hidden" name="caste" value="<?php echo $caste; ?>"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" id="submit" name="submit" class="btn btn-info" value="save"></td>
</tr>
</tbody>
</table>
</form>
// your code
I don't see any code where you're inserting the form data into the table, you should have a code block like this in another page(where you have displayed the form data and has the save button):
if(isset($_POST['submit'])){
$roll = $_POST['roll'];
$sname = $_POST['sname'];
$fname = $_POST['fname'];
$gender = $_POST['gender'];
$aadhar = $_POST['aadhar'];
$caste = $_POST['caste'];
// your INSERT operation
}
code for order.html.php:
<body>
<p> Place order</p>
<table>
<thead>
<tr>
<th>Item No.</th>
<th>Name</th>
<!--<th>Mrp</th>-->
<th>Price</th>
<th>Quantity</th>
</tr>
</thead>
<form id="form1" action="" method="post" >
<tbody>
<?php $id = 0 ;foreach ($dataProduct as $productData): ?>
<tr>
<td><?php echo ++$id ; ?></td>
<td><?php echo $productData['productName']; ?></td>
<td><?php echo $productData['productPrice'];?></td>
<td><input type="number" name="<?php echo $productData['productId']; ?>"/></td>
</tr>
<?php endforeach; ?>
<div><input type="hidden" name="add" value="placeorder"/>
<input type="submit" value="Place Order"/>
<div>
</tbody>
</form>
</table>
</body>
and dom presented in developer tool is:
<body>
<p> Place order</p>
<div><input type="hidden" name="add" value="placeorder">
<input type="submit" value="Place Order">
<div>
</div></div>
<table>
<thead>
<tr>
<th>Item No.</th>
<th>Name</th>
<!--<th>Mrp</th>-->
<th>Price</th>
<th>Quantity</th>
</tr>
</thead>
<form id="form1" action="" method="post" ></form>
<tbody>
<tr>
<td>1</td>
<td>hp keyboard old</td>
<td>400</td>
<td><input type="number" name="1"></td>
</tr>
<tr>
<td>2</td>
<td>lenovo keyboard old</td>
<td>450</td>
<td><input type="number" name="2"></td>
</tr>
<tr>
<td>3</td>
<td>kaspersky antivirus</td>
<td>430</td>
<td><input type="number" name="9"></td>
</tr>
</tbody>
</table>
</body>
see the position of submit and in order.html.php and the resulted dom.
because of this dom structure order.html.php is not able to submit value that resides in input filed.
here is the post with related issue but not exactly what is represent here,
Retrieve data from HTML table to PHP
Try proper html structure :
<body>
<p> Place order</p>
<form id="form1" action="" method="post" >
<table>
<thead>
<tr>
<th>Item No.</th>
<th>Name</th>
<!--<th>Mrp</th>-->
<th>Price</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<?php $id = 0 ;foreach ($dataProduct as $productData): ?>
<tr>
<td><?php echo ++$id ; ?></td>
<td><?php echo $productData['productName']; ?></td>
<!--<td><?php echo $productData['mrp']; ?></td>-->
<td><?php echo $productData['productPrice'];?></td>
<td><input type="number" name="<?php echo $productData['productId']; ?>"/></td>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="4">
<input type="hidden" name="add" value="placeorder"/>
<input type="submit" value="Place Order"/>
</td></tr>
</tbody>
</table>
</form>
</body>
First off, just wrap the table with the <form> tag.
Second, it's not really good to use productId as your name="$productId", instead, use something like name="products[$productId]" so that after form submission, they will be grouped on the same variable as an array.
Sample Code: Sample Demo
$dataProduct = array(
array('productId' => 1, 'productName' =>'hp keyboard old', 'productPrice' => 400),
array('productId' => 2, 'productName' =>'lenovo keyboard old', 'productPrice' => 430),
array('productId' => 9, 'productName' => 'kaspersky antivirus', 'productPrice' => 430),
);
if(isset($_POST['submit'])) {
$values = $_POST['products']; // get all the grouped values
$total = array();
foreach($values as $productId => $quantity) { // loop values
foreach($dataProduct as $productData) {
if($productData['productId'] == $productId) {
// simple multiplication, quantitiy times price for each item
$total[$productId] = $productData['productPrice'] * $quantity;
}
}
}
echo '<pre>';
print_r($total);
echo '</pre>';
}
?>
<form method="POST">
<table cellpadding="10">
<thead>
<tr>
<th>Item No.</th>
<th>Name</th>
<!--<th>Mrp</th>-->
<th>Price</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<?php $id = 0 ; foreach($dataProduct as $productData): ?>
<tr>
<td><?php echo ++$id ; ?></td>
<td><?php echo $productData['productName']; ?></td>
<td><?php echo $productData['productPrice'];?></td>
<td><input type="number" name="products[<?php echo $productData['productId']; ?>]"/></td>
</tr>
<?php endforeach; ?>
<tr>
<td><input type="submit" name="submit" /></td>
</tr>
</tbody>
</table>
</form>
So for example, in the form, I inputted in all of textboxes a quantity of 2. print_r() should yield like this:
Array
(
[1] => 800
[2] => 860
[9] => 860
)
Indices as the keys, the values are the totals for each quantity times price
I have a form that consists of a table with four data cells for comparison in it and also each column has a check box. When I click on the checkbox and submit the form then I want to display only the checked tables in new page. How can I do that? Can anyone help me with working example?
<!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=utf-8" />
<title>Comparision of Printers</title>
</head>
<body>
<form action="newpage.php" method="get">
<table width="1023" border="1">
<tr>
<td width="193"></td>
<td class="p1" width="113"><img src="images/upmini.png"/>
<label>
<input type="checkbox" name="p[]" value="Printer1" id="CheckboxGroup1_0" />
Printer1</label>
</td>
<td class="p2" width="67"><img src="images/upmini.png"/>
<label>
<input type="checkbox" name="p[]" value="Printer2" id="CheckboxGroup1_1" />
Printer2</label></td>
<td class="p3" width="67"><img src="images/upmini.png"/><label>
<input type="checkbox" name="p[]" value="Printer3" id="CheckboxGroup1_2" />
Printer3</label></td>
<td class="p4" width="67"><img src="images/upmini.png"/><label>
<input type="checkbox" name="p[]" value="Pritner4" id="CheckboxGroup1_3" />
Printer4</label></td>
</tr>
<tr>
<td>Title</td>
<td class="p1" >Printer1</td>
<td class="p2" >Printer2</td>
<td class="p3" >Printer3</td>
<td class="p4" >Printer4</td>
</tr>
<tr>
<td>Manufacturer</td>
<td class="p1" >Personal Portable 3DPrinters (PP3DP) founded by Be</td>
<td class="p2" >Personal Portable 3DPrinters (PP3DP) founded by Be</td>
<td class="p3" >Personal Portable 3DPrinters (PP3DP) founded by Be</td>
<td class="p4" >Personal Portable 3DPrinters (PP3DP) founded by Be</td>
</tr>
</table>
<input type="submit" name="compare" value="compare" />
</form>
</body></html>
I think you should use POST instead of GET and store your printer and manufacturer information in a array. i use a 2D array to store the information to make it easy. and get the key values of this array in GET REQUEST and than print only those which match the keys. very simple..
this is full functional code ( changed little bit )
Comparision of Printers
</head>
<body>
// store your infomation in a arrya and use KEY same as in your form checkbox name
<?php
$printers = array(
'printer1' => array(
'title' => 'printer1',
'manufacturer' => 'Personal Portable 3DPrinters (PP3DP) founded by Be 1'
),
'printer3' => array(
'title' => 'printer2',
'manufacturer' => 'Personal Portable 3DPrinters (PP3DP) founded by Be 2'
),
'printer2' => array(
'title' => 'printer3',
'manufacturer' => 'Personal Portable 3DPrinters (PP3DP) founded by Be 3'
),
'printer4' => array(
'title' => 'printer4',
'manufacturer' => 'Personal Portable 3DPrinters (PP3DP) founded by Be 4'
)
)
?>
//if form submited then print the submited index only
<?php if(isset($_GET['p'])):?>
<?php $printerIndex = $_GET['p'];?>
<table width="1023" border="1">
<td>Title</td>
<?php foreach($printerIndex as $index): ?>
<td class = "p1" ><?php echo $printers[$index]['title']; ?></td>
<?php endforeach; ?>
</tr>
<tr>
<td>Manufacturer</td>
<?php foreach($printerIndex as $index): ?>
<td class = "p1" ><?php echo $printers[$index]['manufacturer']; ?></td>
<?php endforeach; ?>
</tr>
</table>
<?php endif; ?>
//make the table
<?php if(!isset($_GET['p'])): ?>
<form action="" method="get">
<table width="1023" border="1">
<tr>
<td width="193"></td>
<?php foreach($printers as $printer ): ?>
<td class="p1" width="113"><img src="images/upmini.png"/>
<label> <?php echo $printer['title']; ?></label>
<input type="checkbox" name="p[]" value="<?php echo $printer['title']; ?>" id="CheckboxGroup1_0" />
</td>
<?php endforeach; ?>
</tr>
<tr>
<td>Title</td>
<?php foreach($printers as $printer): ?>
<td class = "p1" ><?php echo $printer['title']; ?></td>
<?php endforeach; ?>
</tr>
<tr>
<td>Manufacturer</td>
<?php foreach($printers as $printer): ?>
<td class = "p1" ><?php echo $printer['manufacturer']; ?></td>
<?php endforeach; ?>
</tr>
</table>
<input type="submit" name="compare" value="compare" />
</form>
<?php endif; ?>
</body></html>
The checked printers are stored as array p in the $_GET variable. Eg. checking printer 1 and 3 in your example will show the following result:
<?php var_dump($_GET) ?>
array
'p' =>
array
0 => string 'Printer1' (length=8)
1 => string 'Printer3' (length=8)
'compare' => string 'compare' (length=7)
You have only ONE table with several TDs.
So within newpage.php you can do sth like:
if (isset($_GET['P']))
{
$P = $_GET['P'];
for ($i=0;$i<sizeof($P);$i++)
{
// Show what you like, e.g.
echo "Printer".$P[$i]."<br />";
}
}
Is it what you've meant?
I am using following form but when I am submitting form without entering any mandatory fields, then in other input fields values are converting into garbage values.
<?php echo form_open_multipart($formAction); ?>
// form action is coming from controller
<div id="content">
<table border="0" cellpadding="0" cellspacing="5" width="100%" >
<tr>
<td>First Name<em>*</em></td>
<td>
<?php
$data = array('name' => 'firstName');
echo form_input($data, $firstName);
?>
</td>
</tr>
<tr>
<td>Middle Name<em>*</em></td>
<td>
<?php
$data = array('name' => 'middleName');
echo form_input($data, $middleName);
?>
</td>
</tr>
<tr>
<td>Last Name<em>*</em></td>
<td>
<?php
$data = array('name' => 'lastName');
echo form_input($data, $lastName);
?>
</td>
</tr>
<tr>
<td colspan="2">
<div class="formbuttons">
<?php echo form_submit('submit', "Save", "class='button'"); ?>
</div>
</td>
</tr>
</table>
<?php echo form_close(); ?>
If I enter "test's" in first name field and submit form without entering other mandatory fields then in First Name text box it is showing test's.
Try this..
echo form_input($data, html_entity_decode($firstName,ENT_QUOTES));
this should work.