Advertisement
Jaddeee

edit_user

Mar 15th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <html><body background = "vv.jpg">
  2. </html>
  3. <?php
  4. echo '<h1>Edit a User</h1>';
  5. if ((isset($_GET['id'])) && (is_numeric($_GET['id']))){
  6. $id=$_GET['id'];
  7. } else if ((isset($_GET['id'])) && (is_numeric($_GET['id']))){
  8. $id=$_GET['id'];
  9. }else {
  10. echo'<p class="error">This page has been accessed in error.</p>';
  11. exit();
  12. }
  13.  
  14. $servername = "localhost";
  15. $username = "root";
  16. $password = "";
  17. $dbname = "test";
  18.  
  19. // Create connection
  20. $link = new mysqli($servername, $username, $password, $dbname);
  21. // Check connection
  22. if (mysqli_connect_errno())
  23. {
  24. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  25. }
  26.  
  27. $q="SELECT firstname, mobilenum from users where user_id=$id";
  28. $result=@mysqli_query($link,$q);
  29.  
  30. if (mysqli_num_rows($result)==1){
  31. $row=mysqli_fetch_array($result,MYSQLI_NUM);
  32. echo '<form action="edit_user.php" method="post">
  33. <p>Name: <input type="text" name="firstname" size="15" maxlength="15" value "' .$row[0].'"/ required></p>
  34. <p>Username: <input type="text" name="mobilenum" size="15" maxlength="15" value "' .$row[1]. '"/required></p>
  35. <p><input type="submit" name="sure" value="submit"/></p>
  36.  
  37. </form>';
  38. } else {
  39. echo '<p class= "error">This page has been accessed in error.</p>';
  40.  
  41. }
  42. mysqli_close($link);
  43.  
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement