Forum Moderators: coopster
Is this process really necessary?
Can I just make form take action on "_self" and have at top of my document "require_once '../../login_details.php';" with all the details?
BTW, my login_details.php is placed outside of root folder.
inside it I have:
if(isset($_POST['register'])){
// do stuff...
}
if(isset($_POST['login'])){
// do stuff...
}
if(isset($_POST['logout'])){
// do stuff...
}
Is this method bad?
if(isset($_POST['register'])){
// do stuff...
}
if(isset($_POST['login'])){
// do stuff...
}
if(isset($_POST['logout'])){
// do stuff...
}
It's entirely possible that as some point, for example, two of any given variable may be present at the same time. So in the above, you would get responses from both conditions.
Use either else if,
if(isset($_POST['register'])){
// do stuff...
}
else if(isset($_POST['login'])){
// do stuff...
}
else if(isset($_POST['logout'])){
// do stuff...
}
else { // default }
or a switch (but see second comment:)
$action = (isset($_POST['action']))?$_POST['action']:'';
switch ($action) {
case 'register':
// create account
case 'login':
// log in
case 'logout':
// clear cookies, delete session
default:
// oops
}
Second, of course, never directly use input without cleansing.