index.php contiene el logueo y una funcion que llama el registro.php
Código PHP:
// conexion a base de dato
<?php require_once('Connections/conexion_user.php'); ?>
<?php
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;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['cuenta'])) {
$loginUsername=$_POST['cuenta'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index1.php";
$MM_redirectLoginFailed = "INDEX.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_conexion_user, $conexion_user);
$LoginRS__query=sprintf("SELECT login, password FROM account WHERE login=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $conexion_user) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
//formulario de logeo
<div id="apDiv1">
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<div align="right">
<table width="371" border="0">
<tr>
<td width="155" height="28"><span id="sprytextfield1">
<label>
<input name="cuenta" type="text" id="cuenta" value="Cuenta" />
</label>
<span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
<td width="151"><span id="sprytextfield2">
<label>
<input name="password" type="password" id="password" value="Password" />
</label>
<span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
<td width="30"><input type="submit" name="button" id="button" value="Entrar" /></td>
<td width="17"><input type="reset" name="button2" id="button2" value="Limpiar" /></td>
</tr>
<tr>
<td height="27" colspan="4">Has Olvidado la Clave</td>
</tr>
</table>
</div>
</form>
</div>
<div class="sidebar1">
<div id="content"> <div id="content">
<div class="con-wrap">
<div id="fuibar"><!--xxxxxxxxxx-->
<h3 align="right">
<?= date("d/m/Y"); ?></span></h3>
<h3 align="right"><span>
<?php
date_default_timezone_set("America/Caracas" ) ;
$hora = date('h:i a',time() - 3600*date('I'));
print " $hora ";
?>
</h3>
</div>
<br />
</center>
<center>
<object width="370" height="290"><param name="movie" value="http://www.youtube.com/v/F3Id9qf3YC0"></param><embed src="http://www.youtube.com/v/F3Id9qf3YC0" type="application/x-shockwave-flash" width="370" height="290"></embed></object>
</center>
</div></div>
</div>
</div>
</div></div>
</div>
</div>
</div></div>
<!-- end .sidebar1 -->
//esto llama al registro.php
<?PHP
$includeDir = ".".DIRECTORY_SEPARATOR;
DIRECTORY_SEPARATOR;
$includeDefault = $includeDir."registro.php";
if(isset($_GET['s']) && !empty($_GET['s']))
{
$_GET['s'] = str_replace("\0", '', $_GET['s']);
$includeFile = basename(realpath($includeDir.$_GET['s'].".php"));
$includePath = $includeDir.$includeFile;
if(!empty($includeFile) && file_exists($includePath))
{
include($includePath);
}
else
{
include($includeDefault);
}
}
else
{
include($includeDefault);
}
?>
<!-- end .content --></div>
<!-- end .container -->
</div>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
</script>
</body>
</html>