Redisplay a form with updated data
<p>I'm fairly new to php and have a problem with redisplaying a form with upadated data;</p>

<p>The story so far:</p>

<p>I have Register and Logon pages which identify a 'user' by email address; on LOGIN the user is taken to theri own 'member' page which will display the personal data held on that person. They are then invited to edit that data if they wish. This will take them to an 'Update' page and on completion the database is updated via a (hidden) 'update+ac' page and then back to their own 'master' page. The problem is that I cannot get the 'member' page to then redisplay the updated data in a form nor can I get the form itself to redisplay.</p>

<p>Here is the relevent code for the 'member' page: (I have not coded any security or validation as yet - ths is all on localhost - I want ot get the coding right first)</p>

<pre><code>&lt;?php
        include_once 'login.php';
        include_once 'functions.php';

        if (isset($_SESSION['user']))
            {
            $user = $_SESSION['user'];        

        mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
        mysql_select_db($dbname) or die("Unable to connect: " . mysql_error());

        $data = "SELECT * FROM `names` WHERE email='$user'";
        $result=mysql_query($data) or die(mysql_error());
    while($row=mysql_fetch_array($result)){
    }
?&gt;
    &lt;table border='1px' style="background-color:#F0F8FF; font-weight: bold;" &gt;
        &lt;caption&gt;Personal Record&lt;/caption&gt;

    &lt;tr&gt;
    &lt;th&gt;ID&lt;/th&gt;
        &lt;td&gt;&lt;?php
            echo $row['id'];
         ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;th&gt;Name&lt;/th&gt;
        &lt;td&gt;&lt;?php
            echo $row['name'];
         ?&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
    &lt;th&gt;E-Mail&lt;/th&gt;
        &lt;td&gt;&lt;?php
            echo $row['email'];
         ?&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
    &lt;th&gt;Main Telephone&lt;/th&gt;
        &lt;td&gt;&lt;?php
            echo $row['maintel'];
         ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;th&gt;Mobile Telephone&lt;/th&gt;
        &lt;td&gt;&lt;?php
            echo $row['mobtel'];
         ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;th&gt;Organisation&lt;/th&gt;
        &lt;td&gt;&lt;?php
            echo $row['organisation'];
         ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;th&gt;Group Leader&lt;/th&gt;
        &lt;td&gt;&lt;?php
            echo $row['group_leader'];
         ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;th&gt;Supervisor&lt;/th&gt;
        &lt;td&gt;&lt;?php
            echo $row['supervisor'];
         ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;th&gt;Volunteer&lt;/th&gt;
        &lt;td&gt;&lt;?php
            echo $row['volunteer'];
         ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;th&gt;Assessor&lt;/th&gt;
        &lt;td&gt;&lt;?php
            echo $row['assessor'];
            }

         ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;


        &lt;p&gt;&lt;br /&gt;
        &lt;form method="post" action="update.php"&gt;
            &lt;input name="Submit1" type="submit" value="Edit" style="width: 67px" /&gt;&lt;/form&gt;
        &lt;/p&gt;
        &lt;p&gt;&amp;nbsp;&lt;/p&gt;
</code></pre>

<p>The following is the code for the 'update.php' page:</p>

<pre><code>&lt;?php
include_once 'login.php';
        include_once 'functions.php';

    session_start();
// Connect to server and select database.
    mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
        mysql_select_db($dbname) or die("Unable to connect: " . mysql_error());
// get value of id that sent from address bar
            if (isset($_SESSION['user']))
            {
            $user = $_SESSION['user'];
// Retrieve data from database
$sql="SELECT * FROM names WHERE email='$user'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
}
?&gt;
&lt;table width="400" border="0" cellspacing="1" cellpadding="0"&gt;
&lt;tr&gt;
&lt;form name="form1" method="post" action="update_ac.php"&gt;
&lt;td&gt;
&lt;table width="100%" border="0" cellspacing="1" cellpadding="0"&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td colspan="3"&gt;&lt;strong&gt;Update data in mysql&lt;/strong&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="center"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;Name&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;E-Mail&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;Main Tel&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;Mob Tel&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;Organisation&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;Group Leader&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;Supervisor&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;Volunteer&lt;/strong&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;strong&gt;Assessor&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td align="center"&gt;&lt;input name="name" type="text" id="name" value="&lt;? echo $rows['name']; ?&gt;"&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="email" type="text" id="email" value="&lt;? echo $rows['email']; ?&gt;" size="40"&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;input name="maintel" type="text" id="maintel" value="&lt;? echo $rows['maintel']; ?&gt;" size="15"&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;input name="mobtel" type="text" id="mobtel" value="&lt;? echo $rows['mobtel']; ?&gt;"&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;input name="organisation" type="text" id="organisation" value="&lt;? echo $rows['organisation']; ?&gt;"&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;input name="group_leader" type="text" id="group_leader" value="&lt;? echo $rows['group_leader']; ?&gt;"&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;input name="supervisor" type="text" id="supervisor" value="&lt;? echo $rows['supervisor']; ?&gt;"&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;input name="volunteer" type="text" id="volunteer" value="&lt;? echo $rows['volunteer']; ?&gt;"&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;input name="assessor" type="text" id="assessor" value="&lt;? echo $rows['assessor']; ?&gt;"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;input name="id" type="hidden" id="id" value="&lt;? echo $rows['id']; ?&gt;"&gt;&lt;/td&gt;
&lt;td align="center"&gt;&lt;input type="submit" name="Submit" value="Submit"&gt;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/form&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;?
// close connection
mysql_close();
?&gt;
</code></pre>

<p>Finally, here is the code for the 'upate_ac.php' page:</p>

<pre><code>&lt;?php
        include_once 'login.php';
        include_once 'functions.php';
// Connect to server and select database.
mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
        mysql_select_db($dbname) or die("Unable to connect: " . mysql_error());
// update data in mysql database
$id = $_POST['id'];
$name = $_POST['name'];
$email = $_POST['email'];
$maintel = $_POST['maintel'];
$mobtel = $_POST['mobtel'];
$organisation = $_POST['organisation'];
$group_leader = $_POST['group_leader'];
$supervisor = $_POST['supervisor'];
$volunteer = $_POST['volunteer'];
$assessor = $_POST['assessor'];
$sql="UPDATE `names` SET id='$id', `name`='$name', `email`='$email', `maintel`='$maintel', `mobtel`='$mobtel', `organisation`='$organisation', `group_leader`='$group_leader', `supervisor`='$supervisor', `volunteer`='$volunteer', `assessor`='$assessor' WHERE `id`='$id''";
$result=mysql_query($sql);
// if successfully updated.
if($result){
echo "Successful";
echo "&lt;BR&gt;";
echo "&lt;a href='member.php?view=$user'&gt;View result&lt;/a&gt;";
}
else {
echo "ERROR";
}
?&gt;
</code></pre>

<p>What happens is that I get 'Successfull' and 'View Result'. When I click 'View Result' I get taken to the 'member' page but there is no form displayed.</p>

<p>I would appreciate any help.</p>

<p>Regards,</p>

<p>'H'</p>
