Tema: Formularios
Ver Mensaje Individual
  #4 (permalink)  
Antiguo 19/07/2007, 15:24
infoportal
 
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.