Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Problema 24</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- </head>
- <body>
- <!-- Efectuar la modificación del nombre del curso de la tabla "cursos".
- Para la búsqueda ingresar el código de curso.
- -->
- <?php
- if (!isset($_POST['codigo'])){
- ?>
- <form method="post" action="#">
- Seleccione el codigo del curso:
- <input type="text" name="codigo"><br>
- <input type="submit" value="actualizar">
- </form>
- <?php
- }else {
- //conexión
- $conexion=mysql_connect("localhost","root","")
- or die("Problemas en la conexion");
- //selección bbdd
- mysql_select_db("phpfacil", $conexion)
- or die("Problemas en la seleccion de la base de datos");
- //sentencia
- $sentencia=mysql_query ("select * from cursos
- where codigo='".$_POST['codigo']."'",$conexion)
- or die ("error en el select".mysql_err());
- if ($reg=mysql_fetch_array($sentencia))
- {
- while ($reg=mysql_fetch_array($sentencia))
- {
- echo "<form method='post' value='#'>";
- echo "Cambie el nombre de <input type='text' name='nombreviejo' value='".$reg['nombrecur']."'><br>";
- echo "Introduzca el nuevo nombre <input type='text' name='nombrenuevo'><br>";
- echo "<input type='submit' value='cambiar'>";
- echo "</form>";
- //update
- $update=mysql_query("Update cursos
- set ='".$_POST['nombrenuevo']."'
- where nombrecur='".$_POST['nombreviejo']."'",$conexion)
- or die ("problemas en el update".mysql_error());
- echo "se ha actualizado correctamente el nombre";
- }
- }
- else
- {
- echo "no hay ningún curso con este codigo";
- }
- mysql_close($conexion);
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment