tengo este problema,
no se como lograr para crear las sesiones en las paginas, digo tengo logrado la pagina de registro y de identificacion pero no logro poder crear las sesiones para la pagina de perfil.
esta es la pagina de identificar.php
Código PHP:
<?php
session_start();
require_once('Connections/ofertas.php'); ?>
<?php
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['Email'])) {
$loginUsername=$_POST['Email'];
$password=$_POST['Email'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "micuenta.php";
$MM_redirectLoginFailed = "no_usuario.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_ofertas, $ofertas);
$LoginRS__query=sprintf("SELECT Email, Email FROM registrarse WHERE Email='%s' AND Email='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $ofertas) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
// Declara dos variables de sesión y asignarlos
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['']) && true) {
$MM_redirectLoginSuccess = $_SESSION['micuenta.php'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<style type="text/css">
<!--
#ingresar {
position:absolute;
left:500px;
top:250px;
width:350px;
height:25px;
z-index:1;
font-family: "Times New Roman", Times, serif;
font-size: 14px;
font-style: normal;
color: #0066FF;
}
.Estilo1 {
font-size: 12px;
color: #FFFFFF;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body>
<div id="ingresar">
<form method="POST" name="form1" action="<?php echo $loginFormAction; ?>">
<table width="300" align="center">
<tr valign="baseline">
<td><p align="center">
Email:
<input name="Email" type="text" onblur="MM_validateForm('Email','','RisEmail');return document.MM_returnValue" value="" size="20">
<input name="submit" type="submit" value="Ir " />
</p> </td>
</tr>
</table>
<input type="hidden" name="id_registrar" value="">
</form>
</div>
</body>
</html>
<?php include("logo.php"); ?>
<?php include("otromenu.php"); ?>
<?php include("menu.php"); ?>
esta es micuenta.php
Código PHP:
<?php require_once('Connections/ofertas.php'); ?>
<?php
// inicializar la sesión
session_start();
if (isset($_SESSION['micuenta.php']) && true) {
}
// ** Cerrar sesión del usuario actual. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
// Iniciar sesión totalmente a un visitante que tenemos que borrar la sesión varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
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']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE registrarse SET Email=%s WHERE Nombre=%s",
GetSQLValueString($_POST['Email'], "text"),
GetSQLValueString($_POST['Nombre'], "text"));
mysql_select_db($database_ofertas, $ofertas);
$Result1 = mysql_query($updateSQL, $ofertas) or die(mysql_error());
$updateGoTo = "micuenta.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_ofertas, $ofertas);
$query_datos = "SELECT Email, Nombre FROM registrarse";
$datos = mysql_query($query_datos, $ofertas) or die(mysql_error());
$row_datos = mysql_fetch_assoc($datos);
$totalRows_datos = mysql_num_rows($datos);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Bienvenido <?php echo $row_micuenta['Nombre']; ?></title>
<style type="text/css">
<!--
#micuenta {
position:absolute;
left:950px;
top:100px;
width:350px;
height:100px;
z-index:1;
font-family: "Times New Roman", Times, serif;
font-size: 14px;
color: #ffffFF;
}
#Layer1 {
position:absolute;
left:46px;
top:89px;
width:93px;
height:69px;
z-index:1;
}
-->
</style>
</head>
<body>
<div id="micuenta">
<p><a href="<?php echo $logoutAction ?>">Desconectar</a></p>
<p>E-mail : <?php echo $row_datos['Email']; ?></p>
<p>Nombre : <?php echo $row_datos['Nombre']; ?></p>
<p> </p>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input type="text" name="Email" value="<?php echo $row_datos['Email']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Nombre:</td>
<td><input type="text" name="Nombre" value="<?php echo $row_datos['Nombre']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Actualizar registro"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="Nombre" value="<?php echo $row_datos['Nombre']; ?>">
</form>
<p> </p>
</div>
</body>
</html>
<?php
mysql_free_result($datos);
?>
<?php include("logo.php"); ?>
<?php include("otromenu.php"); ?>
<?php include("menus.php"); ?>
me entienden?