Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.63 KB | None | 0 0
  1. <?php
  2. require_once 'header.php';
  3. require_once 'conn.php';
  4. require_once 'functions.php';
  5.  
  6. $userid = $username = $usercognome = $usersesso = $usercitta = $useremail = $password = $accesslvl = '';
  7. $mode = "Create";
  8. if (isset($_SESSION['user_id']))
  9. { $userid = antixsq($_SESSION['user_id']);
  10. $mode = "Edit";
  11.  
  12. if ( isset($_GET['user']) )
  13. {
  14. if ( ($userid == $_GET['user']) || ($_SESSION['access_lvl'] > 2) )
  15. {
  16. $userid = antixsq($_GET['user']);
  17. $mode = "Modify";
  18. }
  19. }
  20. $sql = "SELECT * FROM forum_users WHERE id=".$userid;
  21. $result = mysql_query($sql) or die('Could not look up user data; ' . mysql_error());
  22.  
  23. $row = mysql_fetch_array($result);
  24.  
  25. $username = $row['name'];
  26. $usercognome = $row['cognome'];
  27. (int)$usersesso = (int)$row['sesso'];
  28. $usercitta = $row['citta'];
  29. $passwd = $row['passwd'];
  30. $useremail = $row['email'];
  31. $accesslvl = $row['access_lvl'];
  32. $signature = $row['signature'];
  33. $musica = $row['musica'];
  34. $film = $row['film'];
  35. $TV = $row['TV'];
  36. $libri = $row['libri'];
  37. $sport = $row['sport'];
  38. $hobby = $row['hobby'];
  39. }
  40.  
  41.  
  42. if ($mode == "Edit")
  43. {
  44. include('divsinistra.php');
  45. echo '<div id="content">';
  46. echo '<code><a href="index.php">Home</a> &middot; Impostazioni</code>';
  47. }
  48. global $errors; // questo per rendere disponibile anche nella funzione la matrice contenente gli eventuali errori
  49.  
  50. if(count($errors) != 0){
  51. display_errors();
  52. }
  53. ?>
  54. <center><h2><code><?php echo $mode;?> Account</code></h2></center>
  55. <?php echo '<form method="post" action="transact-user.php">';?>
  56.  
  57. <br />
  58. <table border="0" width="90%" align="center" >
  59. <tr>
  60. <td align="left"><font color="gray"><code>Nome:</code></font></td>
  61. <td><input type="text" class="txtinput" id="nome" name="name" maxlength="30" value="<?php echo $row['name']; ?>"></td>
  62. </tr>
  63.  
  64. <tr>
  65. <td align="left"><font color="gray"><code>Cognome:</code></font></td>
  66. <td><input type="text" class="txtinput" id="nome" name="cognome" maxlength="30" value="<?php echo $row['cognome']; ?>"></td>
  67. </tr>
  68.  
  69. <tr>
  70. <td align="left">
  71.  
  72.  
  73. <legend><font color="gray"><code>Sesso:</code></font></legend></td>
  74. <td align="left">
  75.  
  76. <font color="gray"><code>M</code></font><input type="radio" name="sesso" <?php if ($row['sesso']=="1"){echo 'checked="checked"';} else {(int)$usersesso= "1";}?> value="<?php echo (int)$usersesso ;?>"/>
  77. <font color="gray"><code>F</code></font><input type="radio" name="sesso" <?php if ($row['sesso']=="0"){echo 'checked="checked"';} else {(int)$usersesso= "0";}?> value="<?php echo (int)$usersesso ;?>"/>
  78. <font color="gray"><code>
  79. <?php
  80. if(isset($_SESSION['name'])){
  81. if ($row['sesso'] =="1"){
  82. echo 'Uomo';}
  83. else{ echo 'Donna';
  84. } }
  85. ?>
  86. </code></font>
  87.  
  88. </td>
  89. </tr>
  90.  
  91.  
  92. <tr>
  93. <td align="left"><font color="gray"><code>Città:</code></font></td>
  94. <td>
  95. <input type="text" class="txtinput" id="citta" name="citta" maxlength="30" value="<?php echo $usercitta; ?>"></td>
  96. </td>
  97. </tr>
  98.  
  99. <tr>
  100. <td align="left"><font color="gray"><code>Email:</code></font></td>
  101. <td><input type="text" class="txtinput" id="email" name="email" maxlength="30" value="<?php echo $useremail; ?>"></td>
  102. </tr>
  103.  
  104. <?php
  105.  
  106. if ($mode == "Modify") {
  107. echo "<div><fieldset>\n";
  108. echo " <legend>Access Level</legend>\n";
  109.  
  110. $sql = "SELECT * FROM forum_access_levels ORDER BY access_lvl DESC";
  111. $result = mysql_query($sql,$dbh)
  112. or die('Could not list access levels; ' . mysql_error());
  113.  
  114. while ($row = mysql_fetch_array($result)) {
  115. echo ' <input type="radio" class="radio" id="acl_' .
  116. $row['access_lvl'] . '" name="accesslvl" value="' .
  117. $row['access_lvl'] . '" ';
  118.  
  119. if ($row['access_lvl'] == $accesslvl) {
  120. echo 'checked ';
  121. }
  122. echo '>' . $row['access_name'] . "<br>\n";
  123. }
  124. echo "</fieldset></div>";
  125. }
  126. if ($mode != "Modify") echo "<div id=\"passwords\">";
  127. if ($mode == "Edit") {
  128. if (isset($_GET['error']) and $_GET['error'] == "nopassedit") {
  129. echo "<span class=\"error\">Could not modify passwords.";
  130. echo " Please try again.</span><br>";
  131. }
  132. ?>
  133. <tr>
  134. <td align="left"><font color="gray"><code>Vecchia Password:</code></font></td>
  135. <td><input type="password" id="passwd" name="oldpasswd" maxlength="50" value="<?php if (isset($_SESSION['name'])) {echo $passwd;} ?>"></td>
  136. </tr>
  137. <?php
  138. }
  139. if ($mode != "Modify") {
  140. ?>
  141. <tr>
  142. <td align="left"><font color="gray"><code>Password:</code></font></td>
  143. <td><input type="password" id="passwd" name="passwd" maxlength="50" value="<?php if (isset($_SESSION['name'])) {echo $passwd;} ?>"></td>
  144. </tr>
  145. <tr>
  146. <td align="left"><font color="gray"><code>Verifica Password:</code></font></td>
  147. <td><input type="password" id="passwd" name="passwd2" maxlength="50" value="<?php if (isset($_SESSION['name'])) {echo $passwd;} ?>"></td>
  148. </tr>
  149. <?php }
  150.  
  151. if ($mode != "Modify") echo "</div>";
  152. if ($mode != "Create") {
  153. ?>
  154.  
  155. <table border="0" width="90%" align="center">
  156. <tr>
  157.  
  158. <td align="left"><font color="gray"><code>Firma:</code></font></td>
  159. <td a><textarea name="signature" id="signature" cols="40" rows="1"><?php
  160. echo $signature; ?></textarea></td>
  161. </tr>
  162. <tr>
  163.  
  164. <td align="left"><font color="gray"><code>Musica:</code></font></td>
  165. <td a><textarea name="musica" id="musica" cols="40" rows="1"><?php
  166. echo $musica; ?></textarea></td>
  167. </tr>
  168. <td align="left"><font color="gray"><code>Film:</code></font></td>
  169. <td a><textarea name="film" id="film" cols="40" rows="1"><?php
  170. echo $film; ?></textarea></td>
  171. </tr>
  172. <td align="left"><font color="gray"><code>Programmi TV:</code></font></td>
  173. <td a><textarea name="TV" id="TV" cols="40" rows="1"><?php
  174. echo $TV; ?></textarea></td>
  175. </tr>
  176. <td align="left"><font color="gray"><code>Libri:</code></font></td>
  177. <td a><textarea name="libri" id="libri" cols="40" rows="1"><?php
  178. echo $libri; ?></textarea></td>
  179. </tr>
  180. <td align="left"><font color="gray"><code>Sport:</code></font></td>
  181. <td a><textarea name="sport" id="sport" cols="40" rows="1"><?php
  182. echo $sport; ?></textarea></td>
  183. </tr>
  184. <td align="left"><font color="gray"><code>Hobby:</code></font></td>
  185. <td a><textarea name="hobby" id="hobby" cols="40" rows="1"><?php
  186. echo $hobby; ?></textarea></td>
  187. </tr>
  188.  
  189.  
  190. <?php } ?>
  191. <tr>
  192. <td><input class="blackbutton" type="submit" name="action" value="<?php echo $mode; ?> Account"></td>
  193.  
  194. <?php if ($mode == "Edit") {?>
  195. <td><input type="hidden" name="accesslvl" value="<?php echo $accesslvl; ?>"></td>
  196. <?php } ?>
  197. <td><input type="hidden" name="userid" value="<?php echo $_SESSION['user_id']; ?>"></td>
  198. </tr>
  199.  
  200.  
  201. </table>
  202.  
  203. </form>
  204. </div>
  205. <?php
  206. if ($mode == "Edit") {
  207. include('footer.php');?>
  208. </div>
  209. </body>
  210. </html>
  211. <?php
  212. }?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement