Código PHP:
<?php require_once('../Connections/PAGINA.php');
session_start();
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']);
}
mysql_select_db($database_PAGINA, $PAGINA);
$query_disciplina = "SELECT * FROM clases ORDER BY Nombre ASC";
$disciplina = mysql_query($query_disciplina, $PAGINA) or die(mysql_error());
$row_disciplina = mysql_fetch_assoc($disciplina);
$totalRows_disciplina = mysql_num_rows($disciplina);
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$sesion_name=$_SESSION["MM_Username"];
$ide= "SELECT numid FROM users WHERE user='$sesion_name'";
$result=mysql_query($ide,$PAGINA);
$datos_user=mysql_fetch_array($result);
$id=$datos_user["numid"];
$datos= "SELECT NOMBRE, APELLIDOP, APELLIDOM FROM datos WHERE NOSOCIO='$id'";
$result=mysql_query($datos,$PAGINA);
$data_user=mysql_fetch_array($result);
$name=$data_user["NOMBRE"].' '.$data_user["APELLIDOP"].' '.$data_user["APELLIDOM"];
$nom_alum=$_POST['nombre'];
$apellido=$_POST['apellido'];
$discip=$_POST['disciplina'];
$categ=$_POST['categoria'];
$horario=$_POST['hora'];
$periodo=$_POST['periodo'];
if (!empty($_POST['inscribir'])) // Si se dio click en inscribir se hace la inserción a la bd
{
$curso= "SELECT Nombre FROM clases WHERE CveClase='$discip'";
$result=mysql_query($curso,$PAGINA);
$curso=mysql_fetch_array($result);
$disciplina=$curso["Nombre"];
$curso= "SELECT Nombre FROM subcategorias WHERE CveSub='$categ'";
$result=mysql_query($curso,$PAGINA);
$curso=mysql_fetch_array($result);
$categoria=$curso["Nombre"];
$hr= "SELECT * FROM horarios WHERE CveHr='$horario'";
$result=mysql_query($hr,$PAGINA);
$hr=mysql_fetch_array($result);
$hr['Hora']= substr($hr['Hora'], 0,-3);
$horario=$hr["Hora"]." ".$hr["Dia"];
$insertar= "INSERT INTO inscripciones (NoSocio, Inscribio, Nombre, Apellido, Disciplina, Categoria, Horario, Periodo) values ('$id','$name','$nom_alum','$apellido','$disciplina','$categoria','$horario','$periodo')";
mysql_select_db($database_PAGINA, $PAGINA);
$Result1 = mysql_query($insertar, $PAGINA) or die(mysql_error());
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento sin título</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.Estilo1 {
font-size: 10px;
font-family: Georgia, "Times New Roman", Times, serif;
}
.Estilo2 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 14px;
color: #009933;
text-transform: uppercase;
}
a:link {
color: #0000CC;
text-decoration: none;
}
a:visited {
color: #0066FF;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
.Estilo3 {font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 18px; color: #009933; text-transform: uppercase; }
.Estilo5 {color: #009933}
-->
</style>
</head>
<body>
<div align="right">
<table width="200" border="0">
<tr>
<td><div align="center" class="Estilo2">
<?php
if(!isset($_SESSION["MM_Username"]) ) //Si no existe la sesion lo mandamos al login
Header("Location: http://www.clubtresmarias.com.mx");
echo $_SESSION["MM_Username"];
?>
</div></td>
</tr>
<tr>
<td><div align="center"><a href="../logout.php" onMouseOut="window.status='Tres Marias Residential Golf Club ©'" onMouseOver="window.status='Tres Marias Residential Golf Club ©';return true"class="Estilo1">
</a><a href="../logout.php" class="Estilo1">Cerrar Sesión Socio </a></div></td>
</tr>
</table>
</div>
<p align="center" class="Estilo3">inscripciones</p>