What's new

Closed Simple authentication for php

Status
Not open for further replies.

ribbit

Eternal Poster
Established
Joined
Jan 3, 2020
Posts
656
Reaction
193
Points
394
any idea how to construct a authentication for php? para hind ma bypass yung ibang page?
 
eto po yung auth.php
Code:
<?php
session_start();
if(!isset($_SESSION["usern"])){
header("Location: login.php");
exit(); }
?>
nilgay ko sa ` Index.php ko hind na ako maka pasok sa index
Baka di ka naman nag set ng session variable sa previous page?
 
lahat puba nang page need nang authentication?
Lahat ng page that needs proper auth before access must check if the user is logged in or not. That's when you need to access session variables. Session variable must be set after successful login so that you can check on every page if authentication is made before page access.
 
galito sir

12.png 13.png
 

Attachments

You need to set a proper session variable to make it work. based on your code to process the login request, there's no code there that assigns a value to a session.
Try this one
1649059514592.png

Put this code after switch(){...} structure.
Code:
$_SESSION["usern"] = $usern;
 

Attachments

thru session, tapos conditions.

pag yung session ay di existing, use header or die(header("Location: asdasdsad.com")); do not use javascript.
 
Napagana mo na ba yung login ? Itry mo i echo yung $_SESSION["usern"] kung gumagana na yung session mo.

Naka-gawa kana ng database ?
eto po data base ko

lmaoqwe.png database.png

kapag yung folder lang po nilagay ko matik index po pasok
 

Attachments

Last edited:
Status
Not open for further replies.
Back
Top