below is how i modified the upadate but it does not update at all.
Code:
<html>
<head>
<title> Hostel - Admin </title>
</head>
<body>
<p align="center" > Editting - Hostel Details </p>
<?php
if ($jc=="edit") {
$id = $_POST["id"];
$con= mysql_connect('localhost','aashaba', 'aashaba');
$dab= mysql_select_db('Hostel');
$ql= mysql_query("select * from Hostel where hostelId=$id");
while($we=mysql_fetch_array($ql)){
$hon = $we['hostelName'];
$loc = $we['locationId'];
$hot = $we['hostelType'];
$pad = $we['postalAddress'];
$cap = $we['capacity'];
$cust=$we['custodian'];
$pho = $we['phone'];
$mail = $we['email'];
$rul = $we['rules'];
$custnam=$we['custodianUser'];
$custpas=$we['custodianPass'];
}
}
?>
<form action='view1.php' method='post' name="update">
Hostel Name <input type='text' name='hostelName' value='<? echo $hon ?>' >*<br>
location <input type='text' name='locationId' value='<? echo $loc ?>' >*<br>
hostelType <input type='text' name='hostelType' value='<? echo $hot ?>' ><br>
Postal Address <input type='text' name='postalAddress' value='<? echo $pad ?>' ><br>
Capacity <input type='text' name='capacity' value='<? echo $cap ?>' ><br>
CUstodian <input type='text' name='custodian' value='<? echo $cust ?>' ><br>
Phone <input type='text' name='phone' value='<? echo $pho ?>' ><br>
Email <input type='text' name='email' value='<? echo $mail ?>' ><br>
Terms & Agreements<input type='text' name='rules' value='<? echo $rul ?>' ><br>
Custodian Username <input type='text' name='custodianUser' value='<? echo $custnam ?>' ><br>
Custodian Password<input type='text' name='custodianPass' value='<? echo $custpass?>' ><br>
<br>
<input type="submit" name="sub" value="UPDATE">
Fields with * should not be edited. thank you.<br><br>
</form>
</body>
</html>
<?php
global $id;
echo $id;
$post = $_POST["sub"];
$a = $_POST ["postalAddress"];
$b = $_POST ["capacity"];
$c = $_POST ["custodian"];
$d = $_POST ["phone"];
$z = $_POST ["email"];
$e = $_POST ["rules"];
$f = $_POST ["custodianUser"];
$g = $_POST ["custodianPass"];
if($post="UPDATE")
{
$con= mysql_connect('localhost','aashaba', 'aashaba');
$dab= mysql_select_db('Hostel');
$sql = "UPDATE Hostel SET postalAddress='$a', capacity='$b', custodian='$c',phone='$d', email='$z', rules='$e', custodianUser='$f', custodianPass='$g' WHERE hostelId ='$id'";
if ($result = mysql_query($sql))
{
echo "Thank you! Information updated.\n";
} else { echo mysql_error(); }
}
?>
could some one please help.
Bookmarks