Escolar Documentos
Profissional Documentos
Cultura Documentos
updating)
In this tutorial u will learn following things
How
How
How
How
How
How
to
to
to
to
to
to
Note :
Create a folder in Xamp/ htdocs/
Save all files in the folder.
Save CSS file in same folder.
<div id="login-form">
<form method="post"action ="submit.php">
<table align="center" width="35%" border="0">
<tr>
<td><input type="text" name="customer_name" placeholder="customer
Name" required /></td>
</tr>
<tr>
<td><input type="text" name="contact_name" placeholder="Contact
Name" required /></td>
</tr>
<tr>
<td><input type="text" name="city" placeholder="City" required /></td>
</tr>
<tr>
<td><input type="text" name="country" placeholder="Country" required
/></td>
</tr>
<tr>
<td> <button><input type="submit" name="submit" value ="Enter
Record"></button></td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>
Save this file with register.php
Start apache
Start MySQL
Goto LocalHost/phpmyadmin
Create database with name (raeesdb) here
<?php
include("dbconnection.php");
if($_POST['submit'])
{
$customer_name=$_POST['customer_name'];
$contact_name=$_POST['contact_name'];
$city=$_POST['city'];
$country=$_POST['country'];
if ($con==true )
{
//echo "true con";
mysqli_select_db( $con,$mysql_database) or die("Could not
select database");
}
else{
echo "abc";
}
mysqli_query($con,"INSERT INTO customer(customer_name,
contact_name, city, country )
VALUES('$customer_name','$contact_name','$city','$country')");
header("location: show.php");
mysqli_close($con);
}
?>
Save this file with submit.php
<body>
<?php
include("dbconnection.php");
$selectSQL = 'SELECT * FROM customer';
if( !( $selectRes = mysqli_query($con, $selectSQL) ) ){
echo 'Retrieval of data from Database Failed - #'.mysql_errno().': '.mysql_error();
}else{}
if( mysqli_num_rows( $selectRes )==0 ){
// echo '<tr><td colspan="4">No Rows Returned</td></tr>';
}else{
}
mysqli_close($con);
?>
<div id="header">
<div id="left">
<label>View Customer Detail</label>
</div>
<div id="right">
</div>
</div>
<table align="center" width="75%" border="1">
<thead>
<tr>
<th>Customer ID</th>
<th>Customer Name</th>
<th>Contact Name</th>
<th>City</th>
<th>Country</th>
<th> Delete user<th>
</tr><?php
while( $row = mysqli_fetch_array( $selectRes ) ){
?>
<tr>
<td><?php echo $row['customer_id']; ?></td></td>
<td><?php echo $row['customer_name']; ?></td>
<td><?php echo $row['contact_name'];?></td>
<td><?php echo $row['city']; ?></td>
<td><?php echo $row['country'];?></td>
<td><a href='delete.php?cusid=<?php echo $row["customer_id"]; ?
>'>Delete</a></td>
<td><a href='edit.php?cusid=<?php echo $row["customer_id"]; ?
>'>Edit</a></td>
</tr>
<?php } ?>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>
Your record will be look like this
Note: in this table record is already added
<tr>
<td><input type="text" name="city" value ="<?php echo $user['city'] ?
>"></td>
</tr>
<tr>
<td><input type="text" name="country" value ="<?php echo
$user['country'] ?>"/></td>
</tr>
<tr>
<td><input id="button" type="submit" name="submit" value ="Update
Record"></td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>
Add edit link on show.php page
<td><a href='delete.php?cusid=<?php echo $row["customer_id"]; ?
>'>Delete</a></td>