
05/08/2010, 12:53
|
| | Fecha de Ingreso: julio-2010
Mensajes: 10
Antigüedad: 14 años, 7 meses Puntos: 0 | |
Respuesta: buscar datos <?php session_start(); ?>
<?php /* no security */ ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php include ("db.php") ?>
<?php include ("function.php") ?>
<?php
ob_start();
//get action
$a = @$HTTP_POST_VARS["a"];
//get fields from form
$x_rut = @$HTTP_POST_VARS["x_rut"];
$x_nombre = @$HTTP_POST_VARS["x_nombre"];
// Open Connection to the database
$conn = mysql_connect(HOST, USER, PASS);
mysql_select_db(DB);
switch ($a)
{
case "A":
// Add
$fieldList[] = "`rut`";
$theValue = (!get_magic_quotes_gpc()) ? addslashes($x_rut) : $x_rut;
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
$valList[] = $theValue;
$fieldList[] = "`nombre`";
$theValue = (!get_magic_quotes_gpc()) ? addslashes($x_nombre) : $x_nombre;
$theValue = ($theValue != "") ? " '" . $theValue . "'" : "NULL";
$valList[] = $theValue;
$insertSQL = "INSERT INTO `maestro` (";
for ($i = 0;$i < count($fieldList); $i++) {
$insertSQL .= $fieldList[$i];
if ($i != count($fieldList) - 1) {
$insertSQL .= ",";
};
};
$insertSQL .= ") VALUES (";
for ($i = 0;$i < count($valList); $i++) {
$insertSQL .= $valList[$i];
if ($i != count($valList) - 1) {
$insertSQL .= ",";
};
};
$insertSQL .= ")";
$rs = mysql_query($insertSQL, $conn) or die(mysql_error());
mysql_free_result($rs);
mysql_close($conn);
ob_end_clean();
break;
}
?>
<?php include ("header.php") ?>
<script language="JavaScript" src="ew.js"></script>
<script language="JavaScript">
<!-- start Javascript
function EW_checkMyForm(EW_this) {
if (!EW_hasValue(EW_this.x_rut, "TEXTAREA" )) {
if (!EW_onError(EW_this, EW_this.x_rut, "TEXTAREA", "Please enter required field - rut"))
return false;
}
if (!EW_checkinteger(EW_this.x_rut.value)) {
if (!EW_onError(EW_this, EW_this.x_rut, "TEXT", "Incorrect integer - rut"))
return false;
}
if (!EW_hasValue(EW_this.x_nombre, "TEXT" )) {
if (!EW_onError(EW_this, EW_this.x_nombre, "TEXT", "Please enter required field - nombre"))
return false;
}
return true;
}
// end JavaScript -->
</script>
<form onSubmit="return EW_checkMyForm(this);" action="maestroadd.php" method="post">
<p>
<input type="hidden" name="a" value="A">
<table border="0" cellspacing="1" cellpadding="5" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">rut</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><textarea cols=0 rows=0 name="x_rut"><?php echo @$x_rut ?></textarea></font> </td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="submit" name="x_rut" value="buscar">
</tr>
<tr>
<td bgcolor="#0099CC"><font color="#FFFFFF"><font size="-1">nombre</font> </font></td>
<td bgcolor="#F5F5F5"><font size="-1"><input type="text" name="x_nombre" value="<?php echo @$x_nombre ?>" size=30 maxlength=100></font> </td>
</tr>
</table>
<p>
<input type="submit" name="action" value="ADD">
</form>
<?php include ("footer.php") ?> |