Reputation: 3
I am trying to create a simple login system, without MySQL, just so that my clients can log in, and get directed to a page that will have information showing any links to files, and any meetings.
I have got this:
//If the user is validated and every thing is alright, then grant the user access to the secured account page
//otherwise, display error message to the user
if ($vpb_error == '')
{
if(isset($_SESSION['validfullname']) && isset($_SESSION['validusername']) && isset($_SESSION['validemail']) && isset($_SESSION['validpassword']))
{
echo '<font style="font-size:0px;">completed</font>';
}
else
{
echo '<div class="info">Sorry, it seems your information are incorrect and as a result, we are unable to create the required sessions to log you into your account. Please enter your valid account information to proceed. Thanks.</div>';
}
}
else
{
echo $vpb_error;
}
fclose($vpb_databases);
}
}
else
{
echo '<div class="info">Sorry, we could not get your valid username and password to process your login. Please try again or contact this website admin to report this error message if the problem persist. Thanks.</div>';
}
}
//*********************************************************The login process ends here**********************************************************
How can I make it so that if everything is okay, it will then redirect them to a page based on their username, ie if their username was james, they would be sent to james.php.
Cheers Lewis
Upvotes: 0
Views: 52
Reputation: 3742
I'm guessing that the following if statement is the 'success' branch of code.
https://stackoverflow.com/a/768472/296555
<?php
if(isset($_SESSION['validfullname']) && isset($_SESSION['validusername']) && isset($_SESSION['validemail']) && isset($_SESSION['validpassword']))
{
header('Location: '.$_SESSION['validusername'] . '.php');
}
EDIT
You should really look at cleaning up your code; it's quite messy and looks overly complicated. You're mixing HTML and PHP, although not a show stopper, is generally frowned upon. This is where simple/easy-to-use frameworks come in. Even if you don't use them you should spend some time reading them because they do a lot things right and you'll learn more in a week than a lifetime of fumbling through it. Keep going... it's always fun to come back to code that you've written years ago and think, 'Man, I used to suck!'.
Ex.
<?php
// This looks like no error but then...
if ($vpb_error == '')
{
if(isset($_SESSION['validfullname']) && isset($_SESSION['validusername']) && isset($_SESSION['validemail']) && isset($_SESSION['validpassword']))
{
// Mixing HTML directly in a script file
echo '<font style="font-size:0px;">completed</font>';
}
// there is an error here.
else
{
echo '<div class="info">Sorry, it seems your information are incorrect and as a result, we are unable to create the required sessions to log you into your account. Please enter your valid account information to proceed. Thanks.</div>';
}
}
Upvotes: 1
Reputation: 1439
I don't think you'll want separate files for each user. Typically what I would do is once the user is proven to be authorized you redirect them to an authorized page which will then render the application data for your web-app.
This page will essentially be the same for everyone and you can use populate it with the data associated with that user. I am asumming you'd have a links
table and a meetings
table which would associate a user_id
to a meeting/link. You could use a template engine or roll your own in PHP. Depending on how in depth your app starts to get you might want to look towards a template engine to render the HTML though.
Upvotes: 0
Reputation: 1
when the user is validated you can use php header() function.
header('Location: http://www.example.com/'.$_SESSION['username'].'.php');
Upvotes: 0