Foros del Web » Programando para Internet » PHP »

Formularios

Estas en el tema de Formularios en el foro de PHP en Foros del Web. estoy realizando un formulario de inscripcion el primero toma el nombre del capitan del equipo y el nombre del equipo. nesesito que el formulario que ...
  #1 (permalink)  
Antiguo 19/07/2007, 13:48
 
Fecha de Ingreso: abril-2002
Ubicación: las condes
Mensajes: 184
Antigüedad: 22 años
Puntos: 1
Formularios

estoy realizando un formulario de inscripcion el primero toma el nombre del capitan del equipo y el nombre del equipo.

nesesito que el formulario que introdusca los miembros me tome el nombre del equipo o el id de equipo (no se como es más facil)

osea creo que el sistema deberia pasar el parametro de la siguente manera

agregarmiembros.php?nequipo=fuchito1
agregarmiembros.php?id=1

pero no logro hacer que la bd de miembros me guarde el id no se como pasarlo al formulario de ingreso de datos a bd.

saludos

infoportal
__________________
Juan Pablo Sánchez
  #2 (permalink)  
Antiguo 19/07/2007, 14:23
Avatar de ferbux  
Fecha de Ingreso: mayo-2007
Ubicación: por ahí intentado ayudar
Mensajes: 823
Antigüedad: 16 años, 11 meses
Puntos: 6
Re: Formularios

hOLA, mmmm, con ke BD estas trabajando, por ke si le mandas el valor sin comillas en mysql no te lo aceptará.

SALU2
__________________
"Eres grande por que caminas entre gigantes"
  #3 (permalink)  
Antiguo 19/07/2007, 14:38
Avatar de TolerantX  
Fecha de Ingreso: marzo-2006
Ubicación: Guadalajara, México.
Mensajes: 408
Antigüedad: 18 años
Puntos: 10
Re: Formularios

agregarmiembros.php?nequipo=fuchito1&id=1

¿Quieres pasar esas dos variables por el formulario para que se guarden en tu BD?

Si es así en tu formulario agrega un par de campos tipo hidden de la siguiente manera

Código PHP:
<input type="hidden" name="id" value="<?=$_GET['id']?>" />
<input type="hidden" name="nequipo" value="<?=$_GET['nequipo']?>" />
__________________
TolerantX
http://tolerantx.com
Linux User #385226
  #4 (permalink)  
Antiguo 19/07/2007, 15:24
 
Fecha de Ingreso: abril-2002
Ubicación: las condes
Mensajes: 184
Antigüedad: 22 años
Puntos: 1
Re: Formularios

miren tengo el siguente codigo
Código PHP:
<?php require_once('../../../Connections/cpan2l.php'); ?>
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO miembros (nombre, apellido, rut, direccion, field_11, nacimiento, e-mail, npolera, fono) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['apellido'], "text"),
                       
GetSQLValueString($_POST['rut'], "text"),
                       
GetSQLValueString($_POST['direccion'], "text"),
                       
GetSQLValueString($_POST['field_11'], "text"),
                       
GetSQLValueString($_POST['nacimiento'], "text"),
                       
GetSQLValueString($_POST['email'], "text"),
                       
GetSQLValueString($_POST['npolera'], "text"),
                       
GetSQLValueString($_POST['fono'], "text"));

  
mysql_select_db($database_cpan2l$cpan2l);
  
$Result1 mysql_query($insertSQL$cpan2l) or die(mysql_error());
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
  
$insertSQL sprintf("INSERT INTO miembros (nombre, apellido, rut, direccion, field_11, nacimiento, mail, npolera, fono) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['apellido'], "text"),
                       
GetSQLValueString($_POST['rut'], "text"),
                       
GetSQLValueString($_POST['direccion'], "text"),
                       
GetSQLValueString($_POST['field_11'], "text"),
                       
GetSQLValueString($_POST['nacimiento'], "text"),
                       
GetSQLValueString($_POST['mail'], "text"),
                       
GetSQLValueString($_POST['npolera'], "text"),
                       
GetSQLValueString($_POST['fono'], "text"));

  
mysql_select_db($database_cpan2l$cpan2l);
  
$Result1 mysql_query($insertSQL$cpan2l) or die(mysql_error());
}

$colname_Recordset1 "-1";
if (isset(
$_GET['equipo'])) {
  
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['equipo'] : addslashes($_GET['equipo']);
}
mysql_select_db($database_cpan2l$cpan2l);
$query_Recordset1 sprintf("SELECT nombre, apellido, rut, direccion, field_11, nacimiento, mail, npolera, fono FROM miembros WHERE field_11 = '%s'"$colname_Recordset1);
$Recordset1 mysql_query($query_Recordset1$cpan2l) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>
<form method="get" name="form1" action="<?php echo $editFormAction?>">
</form>

    <form method="get" name="form2" action="<?php echo $editFormAction?>">
      <table align="center">
        <tr valign="baseline">
          <td nowrap align="right">Nombre:</td>
          <td><input type="text" name="nombre" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Apellido:</td>
          <td><input type="text" name="apellido" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Rut:</td>
          <td><input type="text" name="rut" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Direccion:</td>
          <td><input type="text" name="direccion" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">:</td>
          <td><input name="field_11" type="hidden" id="field_11" value="<?=$_GET['field_11']?>"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Nacimiento:</td>
          <td><input type="text" name="nacimiento" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Mail:</td>
          <td><input type="text" name="mail" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Npolera:</td>
          <td><input type="text" name="npolera" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Fono:</td>
          <td><input type="text" name="fono" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">&nbsp;</td>
          <td><input type="submit" value="Insertar registro"></td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form2">
    </form>
    <p>&nbsp;</p>
    <?php
mysql_free_result
($Recordset1);
?>
y no logro que el campo oculto que es field_11(segun bd) que pasa por url equipo= algo

no se carga en mi bd
__________________
Juan Pablo Sánchez

Última edición por GatorV; 19/07/2007 a las 15:46 Razón: agregado etiquetas para codigo.
  #5 (permalink)  
Antiguo 19/07/2007, 15:31
Avatar de TolerantX  
Fecha de Ingreso: marzo-2006
Ubicación: Guadalajara, México.
Mensajes: 408
Antigüedad: 18 años
Puntos: 10
Re: Formularios

A ver, field_11 lo sacas de la base de datos? con tu consulta $query_Recordset1??

Si es así entonces en ves de poner $_GET['field_11'] pondrás $row_Recordset1['field_11']
__________________
TolerantX
http://tolerantx.com
Linux User #385226
  #6 (permalink)  
Antiguo 19/07/2007, 19:09
 
Fecha de Ingreso: abril-2002
Ubicación: las condes
Mensajes: 184
Antigüedad: 22 años
Puntos: 1
Re: Formularios

lo que pasa es field_11 esta en una bd que es en la que estan los datos del capitan. pero para saber cuales son los miembros del equipo realizare una consulta condicional para el nombre del equipo.

osea si el capitan es pedro en la bd donde estan sus datos incluye el field_11 con el nombre de su equipo

pero andres juega con pedro en el mismo equipo y pedro lo registra como jugador de su equipo y entonses en la tabla miembros se copia el field_11 de manera automaica que se pasa por url.
__________________
Juan Pablo Sánchez
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:56.