Code en PHP para Registrarse
Code en PHP para Registrarse
php
session_start();
//header("Cache-Control", "no-cache, no-store, must-revalidate");
$nombre = $grupo = $nickname = $clave = "";
if (isset($_POST['Nnombre']) && isset($_POST["Ggrupo"]) &&
isset($_POST["Nnickname"]) && isset($_POST['Cclave']) &&
$_SESSION['checando']="uno") {
global $nombre, $nickname,$clave, $grupo;
$nombre = test_input($_POST['Nnombre']);
$grupo = test_input($_POST['Ggrupo']);
$nickname = test_input($_POST['Nnickname']);
$clave = test_input($_POST['Cclave']);
GrabandoDatos();
//Registrandose();
}
else {
Registrandose();
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
function Registrandose(){
$_SESSION['checando']="uno";
echo '<!DOCTYPE HTML>';
echo '<html>';
echo '<head>';
echo '<meta charset="UTF-8">';
estilos();
echo '<title>User Login Form</title>';
echo '<style>
table, td, th { border: 0px solid black; }
table { border-collapse: collapse; width: 50%; }
th { height: 50px; }
</style>';
echo '</head>';
echo '<body BGCOLOR="#C8C8C8">';
echo '<center>';
if ($_SESSION['UsuarioYaExiste'] == "verdad"){
echo '<H1>!!! El Nickname que habías elegido ya existe. !!!. </H1>';
$_SESSION['UsuarioYaExiste'] = "falso";
}
else if ($_SESSION['UsuarioYaExiste'] == "Faltandatos"){
echo '<H1>!!! Anota tus datos correctamente !!!. </H1>';
$_SESSION['UsuarioYaExiste'] = "falso";
}
//else if ($_SESSION['UsuarioYaExiste'] == "Registrado"){
// echo '<H1>!!! Listo. Ya estas registrado !!!. </H1>';
// $_SESSION['UsuarioYaExiste'] = "falso";
//}
else
echo '<H1>!!! Bienvenido !!! </H1>';
echo '<table>';
echo '</body>';
echo '</html>';
}
function GrabandoDatos(){
echo '<html>';
echo '<head>';
echo '<meta charset="UTF-8">';
echo '</head>';
echo '<body BGCOLOR="#C8C8C8">';
$confirmacion = true;
$file = fopen("RegistroUsuarios.txt","r");
while(! feof($file)){
$records = fgetcsv($file);
// echo "{$records[0]} {$records[1]}<br />";
if ($_POST['Nnickname'] == $records[0] && $_POST['Nnickname']!=""){
$confirmacion = false;
echo '<center>';
echo "<br><br><H1>Nickname ya existe. <br><br><br><br>";
echo '<a href="registrate.php">Ir a página de registro</a> <br>';
echo "</H1>";
//echo "Nickname ya existe. <BR>";
$_SESSION['UsuarioYaExiste'] = "verdad";
}
}
fclose($file);
if ($confirmacion){
$confirmacion = false;
$_SESSION['checando'] = "cero";
//header('Location: registrate.php');
function estilos(){
echo '<style>
h1 { font-size: 50; }
h2 { font-size: 38px; }
h3 { font-size: 26px; }
p { font-size: 10px; }
</style>';
}
?>