Bramdon3000
-
Posts
9 -
Joined
-
Last visited
Posts posted by Bramdon3000
-
-
Just out of curiosity could you tell me a few problems with the code?
-
-
-
-
Deepest apologies,
Going from REQUEST TO GET solved the problem with the warning so thank you.
Furthermore, I think I might have a better understanding of where my issue of the login system not working comes from. But I will like to confilm is there anything wrong here? The code I'm trying to set up is
$select_stmt=$db->prepare("SELECT username,email FROM masterlogin WHERE username=:uname OR email=:uemail");
Finally I will give you guys the full code. Sorry for not showing you it and I send more in enough comment (run out of space)
-
When I get to my login system I get the errors:
Warning: Undefined array key "txt_email" in C:\Users\brand\OneDrive\Desktop\XAMAPP\htdocs\Water Tower 2000\index.php on line 70
Warning: Undefined array key "txt_password" in C:\Users\brand\OneDrive\Desktop\XAMAPP\htdocs\Water Tower 2000\index.php on line 72
Warning: Undefined array key "txt_role" in C:\Users\brand\OneDrive\Desktop\XAMAPP\htdocs\Water Tower 2000\index.php on line 74So I changed the $email = $_REQUEST ["txt_email"]; to $email = $_COOKIE ["txt_email"];
And this got rid of the error, but when I tried to log on it didn't go to the next page, instead get stayed in the login page. Basically, my multi user login system doesn't work. What can I do?
Full Code:
-
Error: Parse error: syntax error, unexpected token "else" in C:\Users\brand\OneDrive\Desktop\XAMAPP\htdocs\Water Tower 2000\index.php on line 139
<?php
require_once 'connection.php';
session_start ();
if(isset ($_SESSION["admin_login"]))
{
header ("location:admin/admin_home.php");
}
if(isset ($_SESSION["parent_login"]))
{
header ("location:parent/parent_home.php");
}
if(isset ($_SESSION["swimmer_login"]))
{
header ("location:swimmer/swimmer_home.php");
}
if (isset ($_REQUEST['btn_login'])) {
$email = $_REQUEST ["txt_email"];
$password = $_REQUEST ["txt_password"];
$email = $_REQUEST ["txt_role"];
if(empty($email)){
$errorMsg[]="please enter yout water tower email";
}
else if(empty($password)){
$errorMsg[]="please enter yout water tower email";
}
else if(empty($role)){
$errorMsg[]="please enter yout water tower email";
}
else if($email AND $password AND $role){
try{
$select_stmt=$db->prepare("SELECT email,password,role FROM masterlogin WHERE email=:uemail
AND password=:upassword AND role=:urole");
$select_stmt->bindParam(":uemail",$email);
$select_stmt->bindParam(":upassword",$password);
$select_stmt->bindParam(":uemail",$role);
$select_stmt->excute();
while ($row=$select_stmt->fetch(PDO::FETCH_ASSOC)){
$dbemail =$row["email"];
$dbpassword =$row["password"];
$dbrole =$row["role"];
}
if($email!=null AND $password!=null AND $role!=null){
if($select_stmt->rowCount()>0){
if ($email!==$dbemail AND $password==$dbpassword AND $role==$dbrole){
switch($dbrole) {
case "admin":
$_SESSION ["admin_login"]=$email;
$loginMsg="Admin...Your in Water Tower...";
header("refresh:3;admin/admin_home.php");
break;
case "parent":
$_SESSION["parent_login"]=$email;
$loginMsg="Parent...Welcome To Water Tower...";
header("refresh:3;parent/parent_home.php");
break;
case "swimmer":
$_SESSION ["swimmer_login"]=$email;
$loginMsg="Fellow swimmer...Your in Water Tower...";
header("refresh:3;swimmer/swimmer_home.php");
break;
default:
$errorMsg[]="Sorry but either the email/password/role is wrong";
}
}
else {
$errorMsg="Sorry but either the email/password/role is wrong";
}
else {
$errorMsg="Sorry but either the email/password/role is wrong";
}
}
else{
$errorMsg="Sorry but either the email/password/role is wrong";
}
}
}
catch (PDOException $e){
$e->getMassage();
}
}
else {
$errorMsg="Sorry but either the email/password/role is wrong";
}
}
?>
-
<?php
$con=mysql_connect ("localhost","root","");
if(!$db) {
echo "Unable to establish connection".mysql_error();
}
$db=mysql_select_db ("Water Tower 2000 r",$con);
if(!$db){
echo "Database not found".mysql_error();
}
if (isset ($_POST ['submit'])) {
$username = $_POST ['username'];
$password = $_POST ['pwd'];
$query="select * from login where username= '$username' and password= '$password' and
type='$type'";
$result=mysql_query($query);
while($row=mysql_fecth_array($result)){
if($row['username']==$username && $row ['password']==$password && $row['type']=='
Admin'){
header ("Location:admin.html");
}else($row['username']==$username && $row ['password']==$password && $row['type']=='
Parent') {
header ("Location:parent.html");
} elseif ($row['username']==$username && $row ['password']==$password && $row['type']=='
Swimmer'){
header ("Location:swimmer.html");
}
}
}
?>
I'm dealing with the error Warning: Undefined array key and a login system that won't work
in PHP Coding Help
Posted
Thanks