te lo ago en dos partes el registro que tengo
la primera parte
Código PHP:
Ver original<?php
// EL PRINCIPIO
require "inc/phpcode/comun_top.php";
//VARIABLES VARIAS
$variables_sustituir->nuevaVariable ("{TITLE}", "Incribirse a los torneos");
//CABECERA
echo $variables_sustituir->parsearTemplate ("inc/template/comun_top.tpl");
// COMPRUEBO SI ESTOY ENVIANDO UN FORMULARIO DE REGISTRO
if (isset ($var_modo) && $var_modo == "submit" && isset ($_SESSION['id_juego'])) {
$error = true;
// OBTENGO EL JUEGO A PARTIR DEL ID
$res = $BD->getTabla ("juegos", "id", $_SESSION['id_juego']);
//COMPROBACIONES
if (count ($res) == 0 || $res[0]["inscripcion_abierta"] != 1) {
header ("Location: registrarse.php"); }
if (!(isset ($_SESSION['numero_seguridad']) && $_SESSION['numero_seguridad'] == $_POST["comprobacion"])) $variables_sustituir->nuevaVariable ("{ERROR}", "ERROR: Codigo de comprobación incorrecto");
else
{ // CODIGO DE SEGURIDAD CORRECTO
// TORNEO INDIVIDUAL
if ($res[0]["numero_jugadores"]==1)
{
$jugador = $_POST["jugador"];
// COMPRUEBO LOS DATOS
if (comprobar_datos_jugador ($jugador))
{
$res2 = $BD->getTabla ("jugadores", "id_juego", $_SESSION['id_juego'], " AND dni = '". strtoupper($jugador["dni"]) ."'");
// SI EL JUGADOR NO ESTABA DADO DE ALTA ANTERIORMENTE EN ESE JUEGO
{
"id_juego" => $_SESSION['id_juego'],
);
$id_jug = $BD->putTabla ("jugadores", $tmp);
//$res2 = $BD->getTabla ("jugadores", "id_juego", $_SESSION['id_juego'], " AND dni = '". strtoupper($jugador["dni"]) ."'");
"id_juego" => $_SESSION['id_juego'],
"id_jugadores" => $id_jug,
"ip_registro" => realip (),
);
$BD->putTabla ("equipos", $tmp);
$error = false;
}else
$variables_sustituir->nuevaVariable ("{ERROR}", "ERROR: El jugador ya esta dado de alta en este juego");
}else
$variables_sustituir->nuevaVariable ("{ERROR}", "ERROR: Datos del jugador incorrectos");
// TORNEO DE EQUIPOS
}else if ($res[0]["numero_jugadores"] > 1)
{
// COMPRUEBO EL CLAN
if (isset ($_POST["clan"]) && trim ($_POST["clan"]) != "") {
$res2 = $BD->getTabla ("equipos", "id_juego", $_SESSION['id_juego'], " AND nombre_clan = '". trim ($_POST["clan"]) ."'"); {
for ($i=0; $i<$res[0]["numero_jugadores"] && !$tmp_error; $i++)
{
$jugador = $_POST["jugador" . $i];
// USO ESTA VARIABLE PARA CONTROLAR CUANDO HAY UN FALLO
$tmp_error = true;
// COMPRUEBO LOS DATOS
if (comprobar_datos_jugador ($jugador))
{
$res2 = $BD->getTabla ("jugadores", "id_juego", $_SESSION['id_juego'], " AND dni = '". strtoupper($jugador["dni"]) ."'");
// SI EL JUGADOR NO ESTABA DADO DE ALTA ANTERIORMENTE EN ESE JUEGO
{
"id_juego" => $_SESSION['id_juego'],
);
$tmp_error = false;
}else
$variables_sustituir->nuevaVariable ("{ERROR}", "ERROR: Un jugador ya esta dado de alta en este torneo");
}else
$variables_sustituir->nuevaVariable ("{ERROR}", "ERROR: Datos de un jugador incorrectos");
}
for ($i=0; $i<$res[0]["numero_suplentes"]; $i++)
{
$jugador = $_POST["suplente" . $i];
// COMPRUEBO LOS DATOS
if (comprobar_datos_jugador ($jugador))
{
$res2 = $BD->getTabla ("jugadores", "id_juego", $_SESSION['id_juego'], " AND dni = '". strtoupper($jugador["dni"]) ."'");
// SI EL JUGADOR NO ESTABA DADO DE ALTA ANTERIORMENTE EN ESE JUEGO
{
"id_juego" => $_SESSION['id_juego'],
);
}else
$variables_sustituir->nuevaVariable ("{ERROR}", "ERROR: Un suplente ya esta dado de alta en este torneo");
}
}
// TODO CORRECTO ASI Q PROCEDO A INTRODUCIR LOS DATOS EN LA BASE DE DATOS
if (!$tmp_error)
{
foreach ($jugadores as $tmp)
{
$id_jugadores[] = $BD->putTabla ("jugadores", $tmp);
//$res2 = $BD->getTabla ("jugadores", "id_juego", $_SESSION['id_juego'], " AND dni = '". $tmp["dni"] ."'");
//$id_jugadores[]=$res2[0]["id"];
}
foreach ($suplentes as $tmp)
{
$id_suplentes[]=$BD->putTabla ("jugadores", $tmp);
//$res2 = $BD->getTabla ("jugadores", "id_juego", $_SESSION['id_juego'], " AND dni = '". $tmp["dni"] ."'");
//$id_suplentes[]=$res2[0]["id"];
}