Hi, new here. Well, i'm not new actually, I've browsed these pages a lot, but first time posting.
I'm setting up a PHP MySQL login on our website and am having problems. Please forgive me as I am very new to PHP.
Basically, I want to delegate account type to an authorization code provided by me and entered by the user during registration. The website I am referring to is for a non-profit so I'll outline what we are attempting.
I would like for there to be one main login page and one main registration page. The user registering is already affiliated with our organization and will receive a packet of information that includes instructions on how to register and an authorization code based on the type of affiliate they are. For example, child sponsor, grant recipient or board member.
The authorization code will tell us a lot, one it will verify their affiliation with the foundation. two, it will identify what type of user to register and three it will link them to the appropriate page upon a successful login.
I found and implemented php code that does all of the mysql interaction, including encrypting passwords. But now I need to figure out how to write the if statements for the authorization code, and then how to forward to a specific page based on login.
I'm using this script: http://phpsense.com/php/php-login-script.html
any help would be greatly appreciated. I'm not very fluent with PHP so be gentle!! Thanks!
PHP Login
Moderator: General Moderators
-
brothaofdes
- Forum Newbie
- Posts: 21
- Joined: Thu Jan 20, 2011 10:05 am
Re: PHP Login
Many many ways to do this.
1. If the code is a fixed type, i.e. always the same code for each type of access, then an if else of the value will suffice
2. If the code is a per user generation, then doing a database lookup and redirecting based on that is what you need
Either way, the if statements are very general and straightforward. here is a snippet from one of my sites. You should get the idea here.
1. If the code is a fixed type, i.e. always the same code for each type of access, then an if else of the value will suffice
2. If the code is a per user generation, then doing a database lookup and redirecting based on that is what you need
Either way, the if statements are very general and straightforward. here is a snippet from one of my sites. You should get the idea here.
Code: Select all
if ($_POST['selAction'] == "ProdDisplay"){
$_SESSION['prodStart']=1;
header("Location: ".$_SESSION['http'].$_SERVER['HTTP_HOST']."/pollerProduction.php");
exit;
}
elseif ($_POST['selAction'] == "machDisplay"){
header("Location: ".$_SESSION['http'].$_SERVER['HTTP_HOST']."/pollerMachineInfo.php");
exit;
}
Re: PHP Login
That's Awesome... pretty much exactly what I needed. The code will be the same for everyone in a specific category.
I just have one more question, in the page that actually registers the user, it has a check that determines whether the field is empty:
Again, I'm a huge newb to PHP. How would I modify that to throw an error if it doesn't match one of the three codes available?
Thanks again, a huge help!!!
I just have one more question, in the page that actually registers the user, it has a check that determines whether the field is empty:
Code: Select all
if($auth == '') {
$errmsg_arr[] = 'Authorization Code is missing. <a href="authorization">What is an Authorization Code?</a>';
$errflag = true;
}
Thanks again, a huge help!!!
-
brothaofdes
- Forum Newbie
- Posts: 21
- Joined: Thu Jan 20, 2011 10:05 am
Re: PHP Login
Form validation is always one of those nasty little administrative duties you need to deal with. It is all custom code that you put into your site to manage content. From what you have already completed, and seen here, doing this little bit of administration should be easy.
Also, to test for a blank entry, always use: isset($text). Works much better than your test.
Also, to test for a blank entry, always use: isset($text). Works much better than your test.