I have a login page (login.php) and one that I would like to display all the user data (profile.php), I researched it and saw that using Sessions would be possible, I made the code based on the examples that vi, but it is returning an error accessing profile.php.
Notice: Undefined index: name in C: \ xampp \ htdocs \ Soldwear \ user \ profile.php on line 28
Notice: Undefined index: last name in C: \ xampp \ htdocs \ Soldwear \ user \ profile.php on line 29
Notice: Undefined index: emaill in C: \ xampp \ htdocs \ Soldwear \ user \ profile.php on line 30
Notice: Undefined index: password in C: \ xampp \ htdocs \ Soldwear \ user \ profile.php on line 31
Notice: Undefined index: phone in C: \ xampp \ htdocs \ Soldwear \ user \ profile.php on line 32
Notice: Undefined index: cpf in C: \ xampp \ htdocs \ Soldwear \ user \ profile.php on line 33
Notice: Undefined index: street in C: \ xampp \ htdocs \ Soldwear \ user \ profile.php on line 34
Notice: Undefined index: number in C: \ xampp \ htdocs \ Soldwear \ user \ profile.php on line 35
Notice: Undefined index: neighborhood in C: \ xampp \ htdocs \ Soldwear \ user \ profile.php on line 36
Notice: Undefined index: city in C: \ xampp \ htdocs \ Soldwear \ user \ profile.php on line 37
I'll leave the codes here, I hope they can help me.
Login.php
<?php require_once('../Connections/db_site.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['email'])) {
$loginUsername=$_POST['email'];
$password=$_POST['senha'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "profile.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_db_site, $db_site);
$sql = "SELECT * FROM clientes WHERE emailClientes=$loginUsername";
$query = mysql_query($sql);
while($sql = mysql_fetch_array($query)){
$nome = $sql["nomeClientes"];
$sobrenome = $sql["sobrenomeClientes"];
$emaill = $sql["emailClientes"];
$senha = $sql["senhaClientes"];
$telefone = $sql["telefoneClientes"];
$cpf = $sql["cpfClientes"];
$rua = $sql["ruaClientes"];
$numero = $sql["numeroClientes"];
$bairro = $sql["bairroClientes"];
$cidade = $sql["cidadeClientes"];
$_SESSION['nome']=$nome;
$_SESSION['sobrenome']=$sobrenome;
$_SESSION['emaill']=$emaill;
$_SESSION['senha']=$senha;
$_SESSION['telefone']=$telefone;
$_SESSION['cpf']=$cpf;
$_SESSION['rua']=$rua;
$_SESSION['numero']=$numero;
$_SESSION['bairro']=$bairro;
$_SESSION['cidade']=$cidade;
}
$LoginRS__query=sprintf("SELECT emailClientes, senhaClientes FROM clientes WHERE emailClientes=%s AND senhaClientes=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $db_site) 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 );
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Entrar - Soldwear</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="../css/styles.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Raleway:300,400,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700|Zilla+Slab:300,400,700" rel="stylesheet">
<link rel="icon" href="../img/logo.png">
</head>
<body>
<header class="cabecalho">
<a href="../index.php">
<h1 class="logo">SOLDWEAR</h1>
</a>
<div class="menu">
<div class="btn-menu"><a href="../index.php"><p class="fa fa-home"></p></a></div>
<div class="btn-menu"><a href="../loja/produtos.php"><p class="fa fa-shopping-cart"></p></a></div>
<div class="btn-menu"><a href="../rastrear.php"><p class="fa fa-map-marker"></p></a></div>
<div class="btn-menu"><a href="profile.php"><p class="fa fa-user"></p></a></div>
</div>
</header>
<div class="corpoSite">
<p>LOGIN</p>
<form ACTION="<?php echo $loginFormAction; ?>" name="form1" method="POST">
<table width="100%" border="0">
<tr>
<td width="100%" class="center"><label>Email:
<input type="text" name="email" id="email">
</label></td>
</tr>
<tr>
<td width="100%" class="center"><label>Senha:
<input type="password" name="senha" id="senha">
</label></td>
</tr>
</table>
<p>
<input name="enviar" type="submit" class="botao" value="Entrar">
</p>
</form>
</div>
<div class="rodape">
<div class="rodapeA">
<p>Soldwear</p>
<p>Rua São Paulo, 973 - Blumenau (SC)</p>
<p>[email protected] | (47) 99970-7076</p>
</div>
<div class="rodapeA">
<p class="fa fa-facebook"></p>
<p class="fa fa-twitter"></p>
<p class="fa fa-instagram"></p>
</div>
</div>
</body>
</html>
profile.php
<!DOCTYPE html>
<html>
<?php session_start(); ?>
<head>
<title>Entrar - Soldwear</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="../css/styles.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Raleway:300,400,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700|Zilla+Slab:300,400,700" rel="stylesheet">
<link rel="icon" href="../img/logo.png">
</head>
<body>
<header class="cabecalho">
<a href="../index.php">
<h1 class="logo">SOLDWEAR</h1>
</a>
<div class="menu">
<div class="btn-menu"><a href="../index.php"><p class="fa fa-home"></p></a></div>
<div class="btn-menu"><a href="../loja/produtos.php"><p class="fa fa-shopping-cart"></p></a></div>
<div class="btn-menu"><a href="../rastrear.php"><p class="fa fa-map-marker"></p></a></div>
<div class="btn-menu"><a href="profile.php"><p class="fa fa-user"></p></a></div>
</div>
</header>
<div class="corpoSite">
<?php
echo $_SESSION['nome'];
echo $_SESSION['sobrenome'];
echo $_SESSION['emaill'];
echo $_SESSION['senha'];
echo $_SESSION['telefone'];
echo $_SESSION['cpf'];
echo $_SESSION['rua'];
echo $_SESSION['numero'];
echo $_SESSION['bairro'];
echo $_SESSION['cidade']; ?>
</div>
<div class="rodape">
<div class="rodapeA">
<p>Soldwear</p>
<p>Rua São Paulo, 973 - Blumenau (SC)</p>
<p>[email protected] | (47) 99970-7076</p>
</div>
<div class="rodapeA">
<p class="fa fa-facebook"></p>
<p class="fa fa-twitter"></p>
<p class="fa fa-instagram"></p>
</div>
</div>
</body>
</html>