Mostrar Mensajes

Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.


Mensajes - Ojkita

Páginas: [1]
1
Hola @César Krall, gracias por contestar.
Ya he resuelto el problema, he pasado los datos a través de $_COOKIE. Lo he dejado así, por si a alguien le interesa.

Código: [Seleccionar]
<?php@setcookie("Matricula",$_POST["Matricula"],time()+243600); //Aquí el cambio?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Modificar Datos</title>
<link rel="stylesheet" href="tabla.css" />
</head>

<body>
<h1>Selecciona la Matr&iacute;cula para modificar los datos</h1>
<?php$conexion = mysqli_connect("localhost:3306", "root", "", "taxicorp");if (!isset($_POST["Matricula"])) {echo ("<form action='cambio.php' method='post'>");$sel = "SELECT Matricula FROM taxis";$exec = mysqli_query($conexion, $sel);$row = mysqli_fetch_array($exec);echo ('<select name="Matricula" id="Matricula">');while ($registro = mysqli_fetch_array($exec)) {echo ('<option>' . $registro["Matricula"] . "</option>");}?>

</select>

<input type="submit" id="cambia" name="cambia" value="enviar" />

<?php} else {$sel = "SELECT * FROM taxis WHERE Matricula='" . $_POST["Matricula"] . "'";$exec = mysqli_query($conexion, $sel);if (!$exec) echo("Error al conectar con la base"  . mysqli_error($conexion));$row = mysqli_fetch_array($exec); //No lo entiendo!!//echo(mysql_result($row,0)); echo("<form action='cambia2.php' method='post'>");?>



<table border="1">
<tr><th colspan="2">Matr&iacute;cula:&nbsp;&nbsp;<font color="red"><strong>
<?php if (isset($_POST["Matricula"])) echo($_POST["Matricula"]); ?>
</strong></font></th></tr>
<tr>
  <td>Modelo:</td>
  <td colspan="1"><input type="text" name="Modelo" required value='
<?php echo($row["Modelo"]); ?>
' /></td>
</tr>
<tr>
  <td>Nombre:</td>
  <td colspan="1">
  <input name="Nombre" type="text" id="Nombre" size="20" required maxlength="20" value='
<?php echo($row["Nombre"]); ?>
'/></td></tr>
  <tr><td>Apellidos:</td><td><input name="Apellidos" type="text" id="Apellidos" size="40" maxlength="40" required value='
<?php echo($row["Apellidos"]); ?>
'/></td>
</TR>
<TR>
  <td><font color="green">Libre:</font></td>
  <td colspan="-1"><input name="libre" type="checkbox" id="libre" value="Libre"
<?php if ($row["Ocupado"]) echo("checked"); ?>
  />
  </td>
</TR>
<TR>
  <td colspan="2" align="center"><input name="enviar" type="submit" id="enviar" value="Modificar Datos" /></td>
  </TR>
</TABLE>
</form>
<?php}?>

</body>
</html>

Aquí recibe los datos...

Código: [Seleccionar]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cambia2</title>
<link rel="stylesheet" href="tabla.css" />
<style type="text/css">
a {
text-decoration:none;
color:#99CC66;
font-weight:600;
}
a:hover {
text-decoration: underline;
color:#99CC66;
font-weight:600;
}
</style>
</head>

<body>
<?php$conexion = mysqli_connect("localhost:3306", "root", "", "taxicorp");//Creamos la sentencia SQL y la ejecutamosecho "Dato recibido de modelo es ".$_POST["Modelo"];echo "Dato recibido de matricula es". $_POST["Matricula"];$sel="UPDATE taxis SET Modelo='" .$_POST["Modelo"] . "'," . "Nombre='" . $_POST["Nombre"] . "',";		$sel.="Apellidos='" . $_POST["Apellidos"] . "',Ocupado=";		if (isset($_POST["libre"]))			$sel.="false";		else			$sel.="true";					    $sel.=" WHERE Matricula='" . $_COOKIE["Matricula"] . "'"; //Aquí la recibe				    $exec=mysqli_query($conexion, $sel);if ($exec)	echo("<H1>Cambio realizado</H1>");else	echo("<H1>Se ha producido un error</H1>");?>

<div align="center"><a href="listado.php">Visualizar el contenido de la base</a></div>
</body>
</html>

Así me ha funcionado.
Gracias y saludos.

2
Buenas a todos!!

Estoy empezando con esto de PHP, bases de datos y estoy haciendo como una especie de Web para una empresa de taxis.

Me da un Warning como si no se enviara un $_POST y no encuentro la solución.
Os dejo el código por si podéis orientar un poco.

Código: [Seleccionar]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Modificar Datos</title>
<link rel="stylesheet" href="tabla.css" />
</head>

<body>
<h1>Selecciona la Matr&iacute;cula para modificar los datos</h1>
<?php$conexion = mysqli_connect("localhost:3306", "root", "", "taxicorp");if (!isset($_POST["Matricula"])) {echo ("<form action='cambio.php' method='post'>");$sel = "SELECT Matricula FROM taxis";$exec = mysqli_query($conexion, $sel);$row = mysqli_fetch_array($exec);echo ('<select name="Matricula" id="Matricula">');while ($registro = mysqli_fetch_array($exec)) {echo ('<option>' . $registro["Matricula"] . "</option>");}?>

</select>

<input type="submit" id="cambia" name="cambia" value="enviar" />

<?php} else {$sel = "SELECT * FROM taxis WHERE Matricula='" . $_POST["Matricula"] . "'";$exec = mysqli_query($conexion, $sel);if (!$exec) echo("Error al conectar con la base"  . mysqli_error($conexion));$row = @mysqli_fetch_array($exec); echo("<form action='cambia2.php' method='post'>");?>

<table border="1">
<tr><th colspan="2">Matr&iacute;cula:&nbsp;&nbsp;<font color="red"><strong>
<?php echo($_POST["Matricula"]); ?>
</strong></font></th></tr>
<tr>
  <td>Modelo:</td>
  <td colspan="1"><input type="text" name="Modelo" required value='
<?php echo($row["Modelo"]); ?>
' /></td>
</tr>
<tr>
  <td>Nombre:</td>
  <td colspan="1">
  <input name="Nombre" type="text" id="Nombre" size="20" required maxlength="20" value='
<?php echo($row["Nombre"]); ?>
'/></td></tr>
  <tr><td>Apellidos:</td><td><input name="Apellidos" type="text" id="Apellidos" size="40" maxlength="40" required value='
<?php echo($row["Apellidos"]); ?>
'/></td>
</TR>
<TR>
  <td><font color="green">Libre:</font></td>
  <td colspan="-1"><input name="libre" type="checkbox" id="libre" value="Libre"
<?php if ($row["Ocupado"]) echo("checked"); ?>
  />
  </td>
</TR>
<TR>
  <td colspan="2" align="center"><input name="enviar" type="submit" id="enviar" value="Modificar Datos" /></td>
  </TR>
</TABLE>
</form>
<?php}?>

</body>
</html>


Estos datos de arriba se envían a la siguiente página, que es donde me aparece el Warning.

Código: [Seleccionar]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cambia2</title>
<link rel="stylesheet" href="tabla.css" />
<style type="text/css">
a {
text-decoration:none;
color:#99CC66;
font-weight:600;
}
a:hover {
text-decoration: underline;
color:#99CC66;
font-weight:600;
}
</style>
</head>

<body>
<?php$conexion = mysqli_connect("localhost:3306", "root", "", "taxicorp");//Creamos la sentencia SQL y la ejecutamos$cambia="UPDATE taxis SET Modelo='" .$_POST["Modelo"] . "'," . "Nombre='" . $_POST["Nombre"] . "',";		$cambia.="Apellidos='" . $_POST["Apellidos"] . "',Ocupado=";		if (isset($_POST["Ocupado"]))			$cambia.="true";		else			$cambia.="false";		    $cambia.=" WHERE Matricula='" . $_POST["Matricula"] . "'"; //Aquí me da el error$exec=mysqli_query($conexion, $cambia);if ($exec)	echo("<H1>Cambio realizado</H1>");else	echo("<H1>Se ha producido un error</H1>");?>

<div align="center"><a href="listado.php">Visualizar el contenido de la base</a></div>
</body>
</html>

Gracias de antemano, saludos.

Páginas: [1]

Sobre la educación, sólo puedo decir que es el tema más importante en el que nosotros, como pueblo, debemos involucrarnos.

Abraham Lincoln (1808-1865) Presidente estadounidense.

aprenderaprogramar.com: Desde 2006 comprometidos con la didáctica y divulgación de la programación

Preguntas y respuestas

¿Cómo establecer o cambiar la imagen asociada (avatar) de usuario?
  1. Inicia sesión con tu nombre de usuario y contraseña.
  2. Pulsa en perfil --> perfil del foro
  3. Elige la imagen personalizada que quieras usar. Puedes escogerla de una galería de imágenes o subirla desde tu ordenador.
  4. En la parte final de la página pulsa el botón "cambiar perfil".