Bueno chicos, lamentablemente tengo que pedirles ayuda, la cosa es que tengo que crear un sistema de torneos, de Padel mas especificamente. la cuestion es que me encontre con un problema, queria crear un archivo que se llamara agregar_jugador.php, en donde, ese formulario, fuera 2 en 1, osea, que pueda agregar usuarios, pero tmb que pueda actualizar los datos.
La cuestion es que me encontre con la duda de como hacerlo, podran darme una mano?.
Saludos
Aqui les dejo el codigo de lo que es el formulario actual ahora.
<?
session_start();
session_cache_limiter('nocache,private');
include ("conectar.php");
if (!isset($_SESSION['usuario'])) { ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form action="agregar_jugador.php" method="POST">
Nombre: <input type="text" name="usuario" id="usuario"><br><!-- Casilla de texto llamada nombre -->
Clave: <input type="password" name="password" id="password"><br><!-- Casilla de password llamada pass -->
<input type="submit" name="login" value="Entrar"><!-- El boton que enviara el form -->
</form>
<?
}
if ($_POST['login']){
$nombre = $_POST[usuario];
$usuario = mysql_query("SELECT usuario,password FROM usuarios WHERE usuario = '$nombre'");
$sql = mysql_fetch_array($usuario);
if ($_POST[password] ==NULL){
echo "Ingrese una contraseña";
} else if ($sql['password'] == $_POST[password]){
$_SESSION["usuario"] = $sql['usuario'];
} else if ($sql['pass'] != $_POST[password]) {
echo "No eres bienvenido aqui";
}
}
if (isset($_SESSION['usuario'])) {
$select = mysql_query("SELECT nombre,apellido FROM jugador");
while ($select2 = mysql_fetch_array($select)){
$nombre = $select2[nombre];
$apellido = $select2[apellido];
$id = $select2[id];
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form action="enviar_jugador.php" method="post" enctype="multipart/form-data" name="agregar_jugador" id="agregar_jugador">
<table width="761" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="197">Nombre</td>
<td width="491"><input type="text" name="nombre" id="nombre" />
</td>
<td width="36"> </td>
<td width="37"> </td>
<td width="37"> </td>
</tr>
<tr>
<td>Apellido</td>
<td><input type="text" name="apellido" id="apellido" /></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Dirección</td>
<td><input type="text" name="direccion" id="direccion" /></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Localidad</td>
<td><input type="text" name="localidad" id="localidad" /></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Telefono</td>
<td><input type="text" name="telefono" id="telefono" /></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Celular</td>
<td><label for="especificaciones">
<input type="text" name="celular" id="celular" />
</label></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>DNI</td>
<td><input type="text" name="dni" id="dni" /></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Fecha de nacimiento</td>
<td><input name="dia" type="text" id="dia" size="4" />
/
<input name="mes" type="text" id="mes" size="4" />
/
<input name="año" type="text" id="año" size="8" />
(DD/MM/AAAA)</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Club</td>
<td><input type="text" name="club" id="club" /></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Foto</td>
<td><input type="text" name="foto" id="foto" /></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Comentarios</td>
<td><textarea name="comentarios" cols="50" rows="5" id="comentarios"></textarea></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Otros</td>
<td><textarea name="otros" cols="50" rows="5" id="otros"></textarea></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="agregar_jugador" id="agregar_jugador" value="Agregar" /></td>
<td><input type="submit" name="modificar_jugador" id="modificar_jugador" value="Modificar" /></td>
<td> </td>
</tr>
</table>
</form>
<? }
}
?>
<?
if (isset($_SESSION[usuario])){
echo "<a href='logout.php'>Desconectar </a>$_SESSION[usuario]";
$session = session_id();
}
?>
</body>
</html>