Guest User

Untitled

a guest
Apr 4th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. else if ($_GET["page"]=="manage"){
  2.  
  3. if(empty($_GET["id"])) {
  4. header("location:member.php");
  5. }
  6. else {
  7. $data_userid=$_GET["id"];
  8. }
  9. $tablename="user";
  10.  
  11. $query= "SELECT * FROM $tablename WHERE user_id='$data_userid'";
  12.  
  13. $result= mysqli_query($connection, $query) or die(mysqli_error($connection));
  14.  
  15. $count= mysqli_num_rows($result);
  16.  
  17. while($row=mysqli_fetch_assoc($result)) {
  18. $datauserid=$row['user_id'];
  19. $datausername=$row['username'];
  20. $datapassword=$row['password'];
  21. $datafirstname=$row['firstname'];
  22. $datalastname=$row['lastname'];
  23. $datagender=$row['gender'];
  24. $dataaddress=$row['address'];
  25. $datacontactnumber=$row['contactnumber'];
  26. $tablename="user";
  27. }
  28. ?>
  29. <br/>
  30. <br/>
  31. <center>
  32. <form name="editAccountForm" id="editAccountForm" method="POST" action="editaccount.php" >
  33. <table name="guestTable" id="guestTable" border="1" >
  34. <tr><th >Username</th>
  35. <td><input style="width:430px; text-align: center" type="text" name="username" value="<?php echo $datausername; ?>"/></td>
  36. </tr>
  37.  
  38. <tr><th >Password</th>
  39. <td><input style="width:430px; text-align: center" type="text" name="password" value="<?php echo $datapassword; ?>" /></td>
  40. </tr>
  41.  
  42. <tr><th >First Name</th>
  43. <td><input style="width:430px; text-align: center" type="text" name="prod_price" value="<?php echo $datafirstname; ?>" /></td>
  44. </tr>
  45.  
  46. <tr><th >Last Name</th>
  47. <td>
  48. <input style="width:430px; text-align: center" type="text" name="lastname" value="<?php echo $datalastname; ?>" /></td>
  49. </td>
  50. </tr>
  51.  
  52. <tr><th >Address</th>
  53. <td>
  54. <input style="width:430px; text-align: center" type="text" name="address" value="<?php echo $dataaddress; ?>" /></td>
  55. </td>
  56. </tr>
  57.  
  58. <tr><th >Contact Number </th>
  59. <td>
  60. <input style="width:430px; text-align: center" type="text" name="contactnumber" value="<?php echo $datacontactnumber; ?>" /></td>
  61. </td>
  62. </tr>
  63. </table><br/>
  64. <input type="submit" value="Save Changes" />
  65. </form>
  66. </center>
  67. <?php
  68. }
  69. ?>
  70.  
  71. <?php
  72. $connect_servername="localhost";
  73. $connect_username="root";
  74. $connect_password="";
  75. $connect_dbname="woven_data";
  76.  
  77. $connection = mysqli_connect($connect_servername, $connect_username, $connect_password);
  78. if (!$connection){
  79. die("Database Connection Failed".mysqli_error($connection));
  80. }
  81.  
  82. $select_db = mysqli_select_db($connection, $connect_dbname);
  83. if (!$select_db){
  84. die("Database Selection Failed".mysqli_error($connection));
  85. }
  86.  
  87. if (isset($_POST['username'])
  88. and isset($_POST['password'])
  89. and isset($_POST['firstname'])
  90. and isset($_POST['lastname'])
  91. and isset($_POST['gender'])
  92. and isset($_POST['address'])
  93. and isset($_POST['contactnumber'])
  94. ){
  95.  
  96. $datauserid=$_POST['user_id'];
  97. $datausername=$_POST['username'];
  98. $datapassword=$_POST['password'];
  99. $datafirstname=$_POST['firstname'];
  100. $datalastname=$_POST['lastname'];
  101. $datagender=$_POST['gender'];
  102. $dataaddress=$_POST['address'];
  103. $datacontactnumber=$_POST['contactnumber'];
  104. $tablename="user";
  105.  
  106. $query="UPDATE $tablename
  107. SET username='$datausername', password='$datapassword',
  108. firstname='$datafirstname', lastname='$datalastname',
  109. gender='$datagender', address='$dataaddress', contactnumber='$datacontactnumber'
  110. WHERE user_id='$datauserid' ";
  111.  
  112. $result=mysqli_query($connection, $query) or die(mysqli_error($connection));
  113.  
  114. if ($result){
  115. header("location:member.php?page=manage&id=$datauserid");
  116. }
  117. else{
  118. header("location:javascript://history.go(-1)");
  119. }
  120. }
  121.  
  122. ?>
Add Comment
Please, Sign In to add comment