Hi, below is the code for my web page. The idea here is, its a phonebook, you click a name to view their individual details and if you want you can click a button which goes to the update.php page which is below.
However, when I make a change to one of the fields, then click my updage (submit) button, it is not updating my database.
(to keep things simple, I made all of my database fields varchars for now)
Can anyone point out where I'm going wrong please?
<html>
<head>
<title>NCFE Phonebook</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="phonebook.css" rel="stylesheet" type="text/css">
</head>
<?php
require "dbheader.inc";
$peopleid = $_GET['peopleid'];
if ($_POST["submit"]) {
$firstname = $_POST["firstname"];
$surname = $_POST["surname"];
$team = $_POST["team"];
$ext = $_POST["ext"];
$tel = $_POST["tel"];
$email = $_POST["email"];
$mobile = $_POST["mobile"];
$jobtitle = $_POST["jobtitle"];
$jobdescription = $_POST["jobdescription"];
$responsibleto = $_POST["responsibleto"];
if ($peopleid > 0) {
$SQLQuery = "UPDATE tblpeople SET firstname = '$firstname',
surname = '$surname',
team = '$team',
ext = '$ext',
tel = '$tel',
email = '$email',
mobile = '$mobile',
jobtitle = '$jobtitle',
jobdescription = '$jobdescription',
responsibleto = '$responsibleto' WHERE id = $peopleid";
}
$Result = mysql_query($SQLQuery);
}
// If the details exist, the code below retrieves the information
if ($peopleid > 0) {
$SQLQuery = "SELECT id, firstname, surname, team, ext, tel, email, mobile, jobtitle, jobdescription, responsibleto FROM tblpeople
WHERE id = $peopleid";
$Result = mysql_query($SQLQuery);
while ($Row = mysql_fetch_array($Result)) {
$id = $Row["id"];
$firstname = $Row["firstname"];
$surname = $Row["surname"];
$team = $Row["team"];
$ext = $Row["ext"];
$tel = $Row["tel"];
$email = $Row["email"];
$mobile = $Row["mobile"];
$jobtitle = $Row["jobtitle"];
$jobdescription = $Row["jobdescription"];
$responsibleto = $Row["responsibleto"];
}
mysql_free_result($Result);
}
?>
<body>
<form action="update.php" method="post" enctype="multipart/form-data" name="update">
<input name="peopleid" type="hidden" value="<?php echo $peopleid; ?>">
<table width="900" border="0" cellspacing="5" cellpadding="5">
<tr class="body">
<td colspan="4">Welcome to the online NCFE All Staff Phonebook - Update an
Entry Screen </td>
</tr>
<tr class="body">
<td colspan="4"><br>
Please enter the appropriate details below and click the Submit button
to update the database.</td>
</tr>
<tr class="body">
<td width="72"> </td>
<td width="237"> </td>
<td width="97"> </td>
<td width="429"> </td>
</tr>
<tr align="left" class="body">
<td>Firstname:</td>
<td><input name="firstname" type="text" class="fieldlength" id="firstname" TABINDEX="1" value="<?php echo $firstname ?>"></td>
<td>Job Title: </td>
<td><input name="jobtitle" type="text" class="fieldlength" id="jobtitle" TABINDEX="8" value="<?php echo $jobtitle ?>"></td>
</tr>
<tr align="left" class="body">
<td>Surname:</td>
<td><input name="surname" type="text" class="fieldlength" id="surname" TABINDEX="2" value="<?php echo $surname ?>"></td>
<td>Job Descripion: </td>
<td rowspan="3" valign="top"><textarea name="jobdescription" rows="5" TABINDEX="9" class="fieldlength" id="jobdescription"><?php echo $jobdescription ?></textarea></td>
</tr>
<tr align="left" class="body">
<td>Team</td>
<td><input name="team" type="text" class="fieldlength" id="team" TABINDEX="2" value="<?php echo $team ?>"></td>
<td> </td>
</tr>
<tr align="left" class="body">
<td>Extension:</td>
<td><input name="ext" type="text" class="fieldlength" id="ext" TABINDEX="4" value="<?php echo $ext ?>"></td>
<td> </td>
</tr>
<tr align="left" class="body">
<td>Telephone:</td>
<td><input name="tel" type="text" class="fieldlength" id="tel" TABINDEX="5" value="<?php echo $tel ?>"></td>
<td>Responsible to:</td>
<td><input name="responsibleto" type="text" class="fieldlength" id="responsibleto" TABINDEX="10" value="<?php echo $responsibleto ?>"></td>
</tr>
<tr align="left" class="body">
<td>Email:</td>
<td><input name="email" type="text" class="fieldlength" id="email" TABINDEX="6" value="<?php echo $email ?>"></td>
<td>Picture:</td>
<td> </td>
</tr>
<tr align="left" class="body">
<td>Mobile:</td>
<td><input name="mobile" type="text" class="fieldlength" id="mobile" TABINDEX="7" value="<?php echo $mobile ?>"></td>
<td> </td>
<td><input name="submit" type="submit" TABINDEX="11" class="body" value="Update">
</td>
</tr>
<tr class="body">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr class="body">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>