<?php
// Use the information in an external file to connect to the database
include("db.php");
//get the needed information from the table in the database
$result = mysql_query("select *
from customer
where cust_no = '$cust_no'");
$row = mysql_fetch_array($result);
$formVars = array();
$formVars["firstname"] = $row["cust_fname"];
$formVars["surname"] = $row["cust_sname"];
$formVars["address"] = $row["cust_address"];
$formVars["postcode"] = $row["cust_postcode"];
$formVars["telephone"] = $row["cust_tel"];
$formVars["email"] = $row["cust_email"];
$formVars["card"] = $row["cust_cc"];
?>
<html>
<head>
<title>Item Search</title>
</head>
<meta name="Author" content="Chetan Ghedia">
<meta name="Version" content="1.1">
<body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" topmargin="0" background="../images/background.jpg" link="#07334A" vlink="#07334A">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="133" height="110"><img src="../images/topleft.jpg" width="133" height="110" border="0" alt=""></td>
<td width="100%" height="110" background="../images/topbg.jpg">
<img src="../images/logocust.jpg" width="269" height="93" border="0" alt="">
</td>
<td width="25" height="110"><img src="../images/topright.jpg" width="25" height="110" border="0" alt=""></td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="100"><img src="../images/spcr.jpg" width="70" height="1" border="0" alt=""></td>
<td width="100%">
<table width="100%" cellpadding="20" cellspacing="0" border="0">
<tr valign="top">
<td>
<center>
<center>
Please Enter The Customer Key Word You Wish To Search Again
<table width="300" border="0">
<tr><td align="center">
<form method="post" name="search"
action="http://meglos.lgu.ac.uk/~cghe11/finalsite/php/itemresult.php"
onsubmit="return checkit()">
<input type="text" name="cussearch" size="15" maxlength="30"
onfocus="this.value=''">
<input type="submit" name="Submit" value="Search">
</form>
</td></tr>
</table>
</center>
<div align="left">
<h2>Customer: <? echo "$cust_no" ; ?> </h2>
</div>
<h1>Customer Details</h1>
<h3>Please fill in the details below to join. Fields shown in <font color="red">red</font> are mandatory.</h3>
<form name="form1" method="post" action="customeredit2.php">
<table>
<col span="1" align="right">
<tr>
<td><input type="hidden" name="cust_no"
value="<? echo "$cust_no";?>"></td>
</tr>
<tr>
<td><font color="red">First name:</font></td>
<td><input type="text" name="firstname"
value="<? echo $formVars["firstname"]; ?>" size=50></td>
</tr>
<tr>
<td><font color="red">Surname:</font></td>
<td><input type="text" name="surname"
value="<? echo $formVars["surname"]; ?>" size=50></td>
</tr>
<tr>
<td><font color="red">Address:</font></td>
<td><input type="text" name="address"
value="<? echo $formVars["address"]; ?>" size=50></td>
</tr>
<tr>
<td><font color="red">Postcode:</font></td>
<td><input type="text" name="postcode"
value="<? echo $formVars["postcode"]; ?>" size=20></td>
</tr>
<tr>
<td><font color="red">Telephone:</font> </td>
<td><input type="text" name="telephone"
value="<? echo $formVars["telephone"]; ?>" size=10></td>
</tr>
<tr>
<td><font color="red">Email</font></td>
<td><input type="text" name="email"
value="<? echo $formVars["email"]; ?>" size=50></td>
</tr>
<tr>
<td><font color="red">Credit Card</font></td>
<td><input type="text" name="card"
value="<? echo $formVars["card"]; ?>" size=50></td>
</tr>
<tr>
<td><input name="submit" type="submit" value="Submit"></td>
</tr>
</table>
</form>
<p><BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
</p>
</p></td>
</tr>
</table>
</td>
<td width="204">
<table width="204" cellpadding="0" cellspacing="0" border="0" background="../images/menubg.jpg">
<tr valign="top">
<td><img src="../images/menutop.jpg" width="204" height="47" border="0" alt="">
<table width="204" cellpadding="13" cellspacing="0" border="0">
<tr valign="top">
<td>
<a href="www.lgu.ac.uk/~cghe11/search/custsearch.html">Login</a><BR>
<a href="www.lgu.ac.uk/~cghe11/search/custsearch.html">Search Catalogue</a><BR>
<a href="www.lgu.ac.uk/~cghe11/search/custsearch.html">Help</a><BR>
<a href="www.lgu.ac.uk/~cghe11/search/custsearch.html">Checkout</a><BR>
<a href="www.lgu.ac.uk/~cghe11/search/custsearch.html">Contact</a><BR> <BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
</td>
</tr>
<tr valign="top">
<td> </td>
</tr>
</table>
<img src="../images/menubottom.jpg" width="204" height="27" border="0" alt=""></td>
</tr>
</table>
<BR><BR><BR>
<BR><BR>
<p align="right"> </p>
</td>
</tr>
</table>
</body>
</html>
as you can see with that code, the formVars as assignment to values in datatabase and show the values correctly.
<?php
// Use the information in an external file to connect to the database
include("db.php");
echo $formVars["firstname"];
// $query = "UPDATE customer SET
// cust_fname = '" . $formVars["firstname"] . "',
// cust_sname = '" . $formVars["surname"] . "',
// cust_address = '" . $formVars["address"] . "',
// cust_postcode = '" . $formVars["postcode"] . "',
// cust_tel = '" . $formVars["telephone"] . "',
// cust_email = '" . $formVars["email"] . "',
// cust_cc = '" . $formVars["card"] . "'
// WHERE cust_no = '" . $cust_no . "'";
//if (!mysql_query($query))
//echo "ERROR";
?>
This doesnt work for some reason, URL is http://www.lgu.ac.uk/~cghe11/finalsite/customersearch.html
search for test 🙂