Estoy realizando una página que tiene dos segmentos, Hogar y empresas. a cada link le creo un parámetro para que me recuerde es que segmento estoy,
Los segmentos están con un id que lo identifica.
En el index.php el usuario selecciona en que segmento y te envía a otra pagina index_xx.php.
para recordar en que segmento estoy, envío el dato por GET.
Código PHP:
<a href="index.xx.php?recordSEG=<?php echo $_GET["recordSEG"]; ?>"
pero el problema se presenta cuando estoy en la página de login o acceso, tan pronto creo el código de conectar usuario con DreamWeaver se pierde y no lo recuerda.
Esto lo entendí porque al poner el cursor sobre el link te muestra esto:
Código PHP:
http://localhost/raiz/registro_usuario.php?recordSEG=2
Código PHP:
http://localhost/zk/inicio_sesion.php?recordSEG=
este es el código de inicio de sesión:
Código PHP:
<?php require_once('Connections/conexion.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['StrEmail'])) {
$loginUsername=$_POST['StrEmail'];
$password=$_POST['strPassword'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "sesion_ok.php?recordSEG=". $GET["recordSEG"];
$MM_redirectLoginFailed = "sesion_error.php?recordSEG=". $GET["recordSEG"];
$MM_redirecttoReferrer = false;
mysql_select_db($database_conexion, $conexion);
$LoginRS__query=sprintf("SELECT strEmail, strPassword FROM tblusuario WHERE strEmail=%s AND strPassword=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $conexion) 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:
Código HTML:
<form name="form1" method="POST" action="<?php echo $loginFormAction; ?>"> <table width="200" border="0" align="center" cellpadding="2" cellspacing="5" id="iniciosesion"> <tr> <td> </td> </tr> <tr> <td><label for="StrEmail"></label> <input name="StrEmail" type="email" required class="campotexto" id="StrEmail" placeholder="Correo Electrónico" size="40"></td> </tr> <tr> <td><label for="strPassword"> <input name="strPassword" type="password" required class="campotexto" id="strPassword" placeholder="Contraseña" size="40"> </label></td> </tr> <tr> <td height="50" align="center" valign="bottom"><input name="button" type="submit" class="boton1" id="button" value="Iniciar Sesión"></td> </tr> <tr> <td align="right" class="contraseña"><a href="#" class="contraseña">¿Olvidó su contraseña?</a></td> </tr> </table> </form> <table width="200" border="0" align="center" cellpadding="2" cellspacing="5"> <tr> <td height="60" align="center" valign="bottom"><a href="registro_usuario.php?recordSEG=<?php echo $_GET["recordSEG"]; ?>" class="registro">Crear mi cuenta</a></td> </tr> </table>
Aclaro que no tengo conocimiento en programación WEB.
Gracias por su ayuda.