<?php require_once('Connections/conex.php'); ?>
<?php
$query = mysql_query("SELECT ID FROM triatlon WERE ID=".$number."");
if ($number >= 280 ){
$extra='finalizado.html';
header("location: $extra");
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 triatlon (nombre, apellido, ci, sexo, nac, categoria, telefono, email ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['apellido'], "text"),
GetSQLValueString($_POST['ci'], "int"),
GetSQLValueString($_POST['sexo'], "text"),
GetSQLValueString($_POST['edad'], "text"),
GetSQLValueString($_POST['categoria'], "text"),
GetSQLValueString($_POST['telefono'], "int"),
GetSQLValueString($_POST['email'], "text"),
mysql_select_db($database_prueba, $prueba);
$Result1 = mysql_query($insertSQL, $prueba);
$error = mysql_error();
if ($error != "")echo 'no hay error';
else{
echo'hay error';
}
}
?>
<!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=utf-8" />
<title>Documento sin título</title>
<script type="text/javascript">
function validar(){
if(document.form1.nombre.value == ""){
alert('Por Favor ingresar Nombre');
}
if(document.form1.apellido.value == ""){
alert('Por Favor ingresar Apellido');
}
if(document.form1.ci.value == ""){
alert('Por Favor ingresar su cedula de identidad');
}
if(document.form1.edad.value == ""){
alert('Por Favor ingresar fecha de nacimiento');
}
if(document.form1.telefono.value == ""){
alert('Por Favor ingresar su número de teléfono');
}
if(document.form1.ci.value == ""){
alert('Por Favor ingresar su cedula de identidad');
}
if ((document.form1.email.value == "") ||
(document.form1.email.value.indexOf('@') == -1) ||
(document.form1.email.value.indexOf('.') == -1)) {
alert('Por Favor ingresar correo electronico valido')
} else {
document.form1.submit();
}
}
</script>
</head>
<body style="alignment-adjust:central">
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1" onsubmit="return validar()">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nombre:</td>
<td><input name="nombre" type="text" value="" size="15" maxlength="15" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Apellido:</td>
<td><input name="apellido" type="text" value="" size="15" maxlength="25" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">CI:</td>
<td><input name="ci" type="text" value="" size="12" maxlength="10" /></td>
</tr>
<tr valign="baseline">
<td align="right" valign="middle" nowrap="nowrap">Sexo:</td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="sexo" value="Masculino" />
Masculino</td>
</tr>
<tr>
<td><input type="radio" name="sexo" value="Femenino" />
Femenino</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fecha de nacimiento:</td>
<td><input name="edad" type="text" value="" size="12" maxlength="12" />
(dd/mm/aa)</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><p>Categoría:</p></td>
<td> <select name="categoria" id="categoria">
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><p>Teléfono:</p></td>
<td><input name="telefono" type="text" value="" size="12" maxlength="11" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><input name="email" type="text" value="" size="32" maxlength="50" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="registro" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>