This is the code that im using to display the data.(registos.php)
<?php
$con = mysqli_connect('localhost','root','');
if (!$con)
{
die('Could not connect: ' . mysqli_error());
}
mysqli_select_db($con,'databaseteste');
$result =mysqli_query($con,("SELECT * FROM `formando2`"));
if (!$result) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
echo "<table class=mainmenu border='1' width=100% >
<p><caption><h1>Registos</h1></caption></p>
<tr>
<th>Primeiro Nome</th>
<th>Ultimo Nome</th>
<th>Numero C.C</th>
<th>Numero contribuinte</th>
<th>Email</th>
<th>Morada</th>
<th>Código postal</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr><form action=update.php method=post>";
echo "<td><input type=text name=pname value='".$row['PrimeiroNome']."'></td>";
echo "<td><input type=text name=sname value='".$row['UltimoNome']."'></td>";
echo "<td><input type=text name=bi value='".$row['NumeroBI']."'></td>";
echo "<td><input type=text name=contri value='".$row['NumeroContribuinte']."'></td>";
echo "<td><input type=text name=email value='".$row['Email']."'></td>";
echo "<td><input type=text name=morada value='".$row['Morada']."'></td>";
echo "<td><input type=text name=cpostal value='".$row['CodigoPostal']."'></td>";
echo "<td><input type=hidden name=id value='".$row['idformando2']."'></td>";
echo "<td><input type=submit></td>";
echo "</tr>";
}
echo "</table>";
?>
This is the code that's giving me the problem i guess, in the update code.(update.php)
<?php
$con = mysqli_connect('localhost','root','');
if (!$con){die('Could not connect: ' . mysqli_error());}
mysqli_select_db($con,'databaseteste');
$update ="update `formando2` 
                set PrimeiroNome='$_POST[pname]',
                    UltimoNome='$_POST[sname]',
                    NumeroBI='$_POST[bi]',
                    NumeroContribuinte='$_POST[contri]',
                    Email='$_POST[email]',
                    Morada='$_POST[morada]',
                    CodigoPostal='$_POST[cpostal]' 
            where idformando2='$_POST[id]'";
if(mysqli_query($con,$update)){
    header("refresh:1; url=registos.php");}
else{
    printf("Error: %s\n", mysqli_error($con));
}   
?>
When i submit it redirect's me to the update.php page then to the registos.php again, but the data still is the same.
Registo Screen
Post update
 
     
     
    