EvilZone
Programming and Scripting => Web Oriented Coding => : bubzuru October 06, 2013, 08:31:21 PM
-
this keeps fucking up for me, can someone give me a basic login page using
sessions , no databases im just getting user pass from a variable
page1.php << create sesion if user pass is correct
page2.php << redirect to page1.php if session is not set >> data
-
<?php
// login.php
@session_start();
define('USERNAME', 'root');
define('PASSWORD', 'toor');
if (@$_SESSION['IS_LOGGED_IN']) {
header("Location: main.php");
}
if (isset($_GET['username'], $_GET['password'])) {
if (USERNAME == $_GET['username'] && PASSWORD == $_GET['password']) {
$_SESSION['IS_LOGGED_IN'] = true;
header("Location: main.php");
} else {
die('Incorrect login.');
}
}
?>
<?php
// main.php
if (!@$_SESSION['IS_LOGGED_IN']) {
header("Location: login.php");
exit;
}
echo 's00per secret text.';
?>
Written in the browser.
-
this is causing the same error i was getting
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept
cookies.
nm fixed it now, you just forgot to add session_start() to main.php
thanx +1
-
im new to this stuff are u working with mysql?
-
im new to this stuff are u working with mysql?
Nope just php if it were MySQL you would see things like SELECT, WHERE, and FROM.
See Here: that is just defining php variables if it were MySQL these would be in a database
- define (http://www.php.net/define)('USERNAME', 'root');
- define (http://www.php.net/define)('PASSWORD', 'toor');
Also right here to retrieve the username and password from the database would be a very different process.
- if (isset (http://www.php.net/isset)($_GET['username'], $_GET['password'])) {
- if (USERNAME == $_GET['username'] && PASSWORD == $_GET['password']) {
ps. I don't want to go too off topic so I won't explain it more besides I don't know php I'm just using what I know from C and MySQL.
-
</thread>