Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. <?php
  2.  
  3. include("datos.php");
  4. include ("funciones.php");
  5.  
  6. $con=conectar ($host,$usuario,$clave,$base);
  7.  
  8. if (!$con){
  9. echo "error" ;
  10. } else{
  11.  
  12. if(($_POST["user"]=="admin" && $_POST["password"]=="admin")){
  13.  
  14. $user=$_POST["user"];
  15. $password=$_POST["password"];
  16. $C=0;
  17. $consulta= "SELECT * FROM usuarios ";
  18. $paquete= consultar($con,$consulta);
  19.  
  20.  
  21. while ($fila=mysqli_fetch_array($paquete)) {
  22. if ($fila["user"]==$user && $fila["password"]==$password) {
  23. $C=$C+1 ;
  24. }
  25. }
  26.  
  27. $consulta= "SELECT * FROM usuarios ";
  28. $paquete= consultar($con,$consulta);
  29.  
  30.  
  31. echo "<table border='1'>";
  32. echo "<td><strong>Id</strong></td>";
  33. echo "<td><strong>Usuario</strong></td>";
  34. echo "<td><strong>Contraseña</strong></td>";
  35.  
  36. while ($fila=mysqli_fetch_array($paquete)){
  37.  
  38. echo "<form action='modificar.php' method='post'>";
  39.  
  40. echo "<tr>";
  41. echo "<td><input type='text' name='id' value='" . $fila['id'] . "'></td>";
  42. echo "<td><input type='text' name='user' value='" . $fila['user'] . "'></td>" ;
  43. echo "<td><input type='text' name='password' value='" . $fila['password'] . "'></td>" ;
  44. echo "</tr>";
  45. }
  46.  
  47. echo "</table>";
  48.  
  49. echo "<input type='submit' name='enviando' value='Modificar'><p>";
  50.  
  51. echo "</form>";
  52.  
  53. }
  54. }
  55. ?>
  56.  
  57. <?php
  58.  
  59. require("datos.php");
  60.  
  61. $id=$_POST["id"];
  62. $user=$_POST["user"];
  63. $password=$_POST["password"];
  64.  
  65.  
  66. $conexion=mysqli_connect($host, $usuario, $clave, $base);
  67.  
  68. if(mysqli_connect_errno()){
  69. echo "fallo al conectar la BBDD";
  70.  
  71. exit();
  72.  
  73. }
  74.  
  75. mysqli_select_db($conexion, $base) or die ("No se encuentra la BBDD");
  76.  
  77. $consulta="UPDATE usuarios SET user='$user', password='$password' WHERE id='$id'";
  78.  
  79. $resultados=mysqli_query($conexion, $consulta);
  80.  
  81. if($resultados==false){
  82.  
  83. echo "Error al modificar registro";
  84. }else{
  85. echo "Registro modificado";
  86.  
  87. }
  88.  
  89. ?>
  90.  
  91. <form action='modificar.php' method='post'>
  92. <input type='text' name='id' value=''/>
  93. <input type='text' name='user' value=''/>
  94. <input type='text' name='password' value=''/>
  95.  
  96. <form action='modificar.php' method='post'>
  97. <input type='text' name='id' value=''/>
  98. <input type='text' name='user' value=''/>
  99. <input type='text' name='password' value=''/>
  100.  
  101.  
  102. <form action='modificar.php' method='post'>
  103. <input type='text' name='id' value=''/>
  104. <input type='text' name='user' value=''/>
  105. <input type='text' name='password' value=''/>
  106.  
  107. ......
  108.  
  109.  
  110.  
  111. <form action='modificar.php' method='post'>
  112. <input type='text' name='id' value=''/>
  113. <input type='text' name='user' value=''/>
  114. <input type='text' name='password' value=''/>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement