edycja danych.php
<?php //polaczenie db include('polaczenie.php'); $sql="SELECT * FROM $tbl_name WHERE login='".$_SESSION['login']."'"; ?> <a href="member.php">Powrót do karty użytkownika</a> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle"> <table width="500" border="0" cellspacing="0" cellpadding="3"> <tr> <td> <table border="0" bordercolor="#000000" style="background-color:#ff6805" width="400" cellpadding="3" cellspacing="3"> <tr> <td align="center"><b>Imię</b></td> <td align="center"><b>Nazwisko</b></td> <td align="center"><b>Email</b></td> <td align="center"><b>Telefon</b></td> </tr> <?php ?> <tr> <tr><td colspan="4" align="center" valign="middle"><a href="update.php?id=<? echo $rows['id']; ?>">Zmien dane</a></td></tr> <?php } ?> </table> </td> </tr> </table> </td></tr></table> <?php ?>
update.php
<?php //polaczenie db include('polaczenie.php'); // get value of id that sent from address bar $id=$_GET['id']; // Retrieve data from database $sql="SELECT * FROM $tbl_name WHERE id='$id'"; ?> <a href="edycjadanych.php">Powrót</a> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle"> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <form name="form1" method="post" action="update_ac.php"> <td> <table width="100%" border="0" bordercolor="#000000" style="background-color:#ff6805" width="400" cellpadding="3" cellspacing="3" > <tr> <td> </td> <td colspan="5" align="center"><strong>PODAJ NOWE DANE</strong> </td> </tr> <tr> <td colspan="5" align="center"> </td> </tr> <tr> <td align="center"> </td> <td align="center"><strong>Imię</strong></td> <td align="center"><strong>Nazwisko</strong></td> <td align="center"><strong>Email</strong></td> <td align="center"><strong>Telefon</strong></td> </tr> <tr> <td> </td> <td align="center"><input name="nazwisko" type="text" id="nazwisko" value="<? echo $rows['nazwisko']; ?>" size="15"></td> </tr> <tr> <tr> <td colspan="5" align="center"></td> </tr> <td colspan="5" align="center"><input type="submit" name="Submit" value="Zapisz nowe dane"></td> </tr> </table> </td> </form> </tr> </table> </td></tr></table> <? // close connection ?>
update_ac.php
<?php //polaczenie db include('polaczenie.php'); // update data in mysql database $sql="UPDATE user SET imie='$imie', nazwisko='$nazwisko', mail='$mail', telefon='$telefon' WHERE id='$id'"; // if successfully updated. if($result){ print '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle"> '; print '<table border="0" bordercolor="#FFFFFF" style="background-color:#ff6805" width="450" cellpadding="3" cellspacing="3">'; print '<tr><td align="center">Za chwile zostaniesz przekierowany na kartę użytkownika <script>setTimeout("document.location = \"member.php\"", 3000);</script> </td></tr></table>'; } else { } ?>