Wednesday, July 4, 2018

Edit Profile (Company Details)


When customer need to update company name, address and telephone numbers, he can do it from the "Edit Profile" option. These information will be printed on invoices and payment receipts. These company details are stored in profile table in mysql database. We have to insert a record using "php my admin" and here we perform only UPDATE operation.

<?php include("header.php"); ?>
<h3>Edit Profile</h3>
<?php
$q = mysql_query("SELECT * FROM profile");
$r = mysql_fetch_assoc($q);
$name = $r['Name'];
$address = $r['Address'];
$telephone = $r['Telephone'];
if(isset($_POST['submit'])){
$name = $_POST['name'];
$address = $_POST['address'];
$telephone = $_POST['telephone'];
if(!empty($name) && !empty($address) && !empty($telephone)){
mysql_query("UPDATE profile SET Name = '$name', Address = '$address', Telephone = '$telephone'");
$noerror = "Profile updated!";
}else{
$error = "Please enter all details!";
}
}
if(isset($error)){
echo "<div class='error'>{$error}</div>";
}
if(isset($noerror)){
echo "<div class='noerror'>{$noerror}</div>";
}
?>
<form method="post" action="edit_profile.php">
<table border="0">
<tr>
<td>Name:</td><td><input type="text" size="40" name="name" value="<?php echo $name; ?>" /></td>
</tr>
<tr>
<td>Address:</td><td><textarea name="address" cols="30" rows="5"><?php echo $address; ?></textarea></td>
</tr>
<tr>
<td>Telephone:</td><td><input type="text" size="40" name="telephone" value="<?php echo $telephone; ?>" /></td>
</tr>
<tr>
<td>&nbsp;</td><td><input class="btn" type="submit" name="submit" value="Update" /></td>
</tr>
</table>
</form>
<?php include("footer.php"); ?>
Share:

0 comments:

Post a Comment