Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Ver producto</title>
- </head>
- <body>
- <form name"ver" action="ver.php" method="GET">
- Id: <input type="text" name="id" /> <br/>
- <input type="submit" name="submit" value="Ver">
- </form>
- <?php
- // Nos conectamos al servidor de la base de datos
- mysql_connect("mysql.amarello.com.mx", "usuario", "password") or die(mysql_error());
- // Seleccionamos la base de datos
- mysql_select_db("cursoseguridad") or die(mysql_error());
- // Si no mandaron nada se termina
- if (!isset($_GET['id'])) {
- die("</body></html>");
- }
- // Guardamos los parámetros que nos mandaron
- $id = $_GET['id'];
- // Construimos la consulta
- $sql = "SELECT * FROM producto WHERE idproducto = '$id'";
- // Ejecutamos la consulta
- $res = mysql_query($sql) or die(mysql_error());
- // Si la consulta devolvió al menos un resultado
- if ($row = mysql_fetch_assoc($res)) {
- ?>
- <table border="1">
- <tr>
- <th>Producto</th>
- <th>Descripcion</th>
- </tr>
- <tr>
- <td><?=$row['producto'] ?></td>
- <td><?=$row['descripcion'] ?></td>
- </tr>
- </table>
- <?php
- }
- // Si la consulta no devolvió resultados
- else {
- ?>
- <br/>No existe el producto
- <?php
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement