What I would like to happen is for the values of the various text boxes to be filled out with the information they have already submitted, they can then edit it and resubmit the form, updating their details.
I have used an echo statement on line 39 to test that the variables are getting correctly filled, which they are. However for example, the DOB text box on the form, displays $dob rather than the contents of $dob.
What am i missing? 😕
The code I am using is below:
<?php
session_start();
include("includelist.php");
include("header.php");
$logged_in=checkLogin();
if($logged_in){
?>
<center>
<table width="75%">
<tr>
<td width="20%">
<img border="0" src="images/wcct_logo_r125.gif" width="125" height="108">
</td>
<td width="60%">
<center><font color="blue" face="Arial"><h1>Personal Information</h1><p>
<h3><i>Please fill in the information about yourself below</i></h3> </font></center>
</td>
<td width="20%">
<img border="0" src="images/wcct_logo_r125.gif" width="125" height="108">
</td>
</tr>
</table></center>
<?php include("hori.php");
$username=$_SESSION['username'];
$dob=getdob($username);
$gender=findgender($username);
$email=getemail($username);
$consent=getconsent($username);
$address=getaddress($username);
$mobphone=getmob($username);
$homephone=gethome($username);
$workphone=getwork($username);
$occ=getocc($username);
$mar=getmar($username);
$gpn=getgpn($username);
$gps=getgps($username);
$gpp=getgpp($username);
echo("$dob" . "/" . "$gender");
?>
<form action="pers_action.php" method="post">
<table align="center" border="0" cellspacing="0" cellpadding="3" width="406">
<tr><td width="246">* Gender:</td><td width="148"><input type="radio" name="gender" value="Male">Male<input type="radio" name="gender" value="Female">Female</td></tr>
<tr><td width="246">* Date of Birth:</td><td width="148"><input type="text" name="dob" maxlength="12" value="<?php echo '$dob'; ?>"></td></tr>
<tr><td width="246">* Email Address:</td><td width="148"><input type="text" name="email" maxlength="40" value="<?php echo '$email'; ?>"></td></tr>
<tr><td width="246">* Confirm Email Address:</td><td width="148"><input type="text" name="email2" maxlength="40" value="<?php echo '$email'; ?>"></td></tr>
<tr><td width="246">* Email Consent:</td><td width="148"><input type="radio" name="emailconsent" maxlength="5" value="Yes">Yes<input type="radio" name="emailconsent" maxlength="5" value="No">No</td></tr>
<tr bgcolor="yellow"><td colspan="2" align="center">May we use your email address to <br>send you treatment follow ups, and <br>occasional newsletters?</td></tr>
<tr><td colspan="2">* Address:</td></tr>
<tr><td width="400" colspan="2"><textarea rows="4" cols="47" name="address"><?php echo '$address'; ?></textarea></td></tr>
<tr><td width="246">* Home Phone:</td><td width="148"><input type="text" name="homephone" maxlength="30" value="<?php echo '$homephone'; ?>"></td></tr>
<tr><td width="246">* Mobile Phone:</td><td width="148"><input type="text" name="mobphone" maxlength="30" value="<?php echo '$mobphone'; ?>"></td></tr>
<tr><td width="246">* Work Phone:</td><td width="148"><input type="text" name="workphone" maxlength="30" value="<?php echo '$workphone'; ?>"></td></tr>
<tr><td width="246">* Your Occupation:</td><td width="148"><input type="text" name="occupation" maxlength="30" value="<?php echo '$occ'; ?>"></td></tr>
<tr><td width="246">* Marital Status/<br>Partners Occupation:</td><td width="148"><input type="text" name="maritalstatus" maxlength="30" value="<?php echo '$mar'; ?>"></td></tr>
<tr><td width="246">GP Name:</td><td width="148"><input type="text" name="gpname" maxlength="30" value="<?php echo '$gpn'; ?>"></td></tr>
<tr><td width="246">GP Surgery:</td><td width="148"><input type="text" name="gpsurgery" maxlength="30" value="<?php echo '$gps'; ?>"></td></tr>
<tr><td width="246">GP Phone:</td><td width="148"><input type="text" name="gpphone" maxlength="30" value="<?php echo '$gpp'; ?>"></td></tr>
<tr><td colspan="2" align="center"><input type="submit" name="details" value="Submit"><input type="reset" value="Clear Form"></td></tr>
</form>
<tr bgcolor="#CCFFCC"><td colspan="2">Please fill in all fields marked with an asterix (*)</td></tr>
<tr bgcolor="#CCFFCC"><td colspan="2">Please <b>note</b> you will need to enter all of your details each time you fill this form in.</td></tr>
</table><p>
<hr color="black"><p>
<center>Please click <a href="members.php">here</a> to go back to the members area without editing your details.</center>
<?php
echo '<center>';
include ("hori.php");
echo '<font size="2">Logged in as '.$_SESSION['username'].', <a href="logout.php">logout</a><br>';
}
else
{
echo 'Not logged in.<p>';
echo 'Please click <a href="login.php">here</a> to login';
echo '<br>Or <a href="register.php">here</a> to register.';
}
?>
</table>
</form>
<?php
include("footer.php");
?>