Need some help
Moderator: General Moderators
Need some help
hi php gurus. how you all doin?. i have one question. i got lots of different answers by googling it but i would like a little bit of description on it. here is what i am trying to do. i have created a website for Division of natural science for my college. i have a link by the name of GIS. what i really want to do is when a user clicks on that GIS link he/she should enter their username and password which they have recieved in order to login to the computers oncampus. like for eg i have my username (szia722@loc.edu) and password(xyz). i had to enter my user id and password to log into campus computer. so once they log in i would redirect them to a page where i have some GIS modules for them to download. how can this be achieved? we are running our own server on campus. hope you understand my question any help will be really appreciated.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
well thanks for the reply. Huggins i can't think of the website name but i dont think it should be hard at all. we have a database in our school in which all the user id are stored. secondly we have iqweb also where people with the same user id and password can log in to the iqweb and check the status of their account like change address or view grades for the semester or how much money they owe to the college etc.. but what i really want is i have a page in html where i have all the files (Gis Modules). i dont want no one else to access that page except the people who are in the college and have a user id and password. they can use the same id and pass to access that page. once they log in i wil redirect them to my html page. hope you understand what i mean. Everah i think that is what i really want. the network administrator have assigned them their user id and password and all i want is when they try to click on log in to access GIS modules a window should pop up asking their user name and password which would be the same they use for iqweb or logging into the computers on campus once the user name and password is correct they should redirected to the GIS html page where they can download the modules. i appreciate any help. if it was just me i am pretty much sure i could have used a script which is available online. but since it is a college website.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
If all you are talking about is a page behind a login, you can do that in one page. Basically you have two portions of the page. If the user is validated (cookie, session, post data, etc) then show the modules. Otherwise, show the login form. You will need a mechanism by which to authenticate the passed credentials, but that seems simple enough.
Mr everah. that is what i really wanted. do you think i should need to contact the administrator who runs the server for the website and iqweb and ask him if he can provide some kind of login script for me to access that page? what if he says no and then what are my options. i bought a book php with mysql which has lots of scripts but still it does not make any sense to me how can i validate people who have user id by the name of user@loc.edu. if you have any script or any url that will be great. Thanks
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
There are plenty of login scripts around. It really depends on the nature of your needs for this script. Basically you are going to need a user data source to grab form/authenticate against. Once the user submits authentication, check the credentials then is they pass, show the content. Otherwise, show them the form again.
i found this authenticate script in my book. but the book tells me that i had to configure my server to do this and that. he said i had to change the http config file in apache. the website is going to be running on our college server. the script is as follow please tell me if this script is of any use.
but in this script we have a password described. any idea on how to change the script for my needs or any other script you would like to share with me ?. you have helped me alot and gave me a good idea Everah in how to achieve this task. appreciated
Code: Select all
<?php
require_once "HTML/Template/ITX.php";
require "db.inc";
function authenticated($username, $password)
{
// If either the username or the password are
// not set, the user is not authenticated
if (!isset($username) || !isset($password))
return false;
// Is the password correct?
// If so, the user is authenticated
if ($password == "kwAlIphIdE")
return true;
else
return false;
}
$template = new HTML_Template_ITX("./templates");
$template->loadTemplatefile("example.11-3.tpl", true, true);
$username = shellclean($_SERVER, "PHP_AUTH_USER", 20);
$password = shellclean($_SERVER, "PHP_AUTH_PW", 20);
if(!authenticated($username, $password))
{
// No credentials found - send an unauthorized
// challenge response
header("WWW-Authenticate: Basic realm=\"Flat Foot\"");
header("HTTP/1.1 401 Unauthorized");
// Set up the body of the response that is
// displayed if the user cancels the challenge
$template->touchBlock("challenge");
$template->show();
exit;
}
else
{
// Welcome the user now they're authenticated
$template->touchBlock("authenticated");
$template->show();
}
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Basically I would ask him to setup either a database for you or add you to a database that already exists and give you permission to a table or two. Basically you are going to need to be able to query user information from somewhere to validate what the user is giving you in the form of a login and password. Once that information is validated, you can show them the content they should see. But the validation needs to be handled first, and to do that you need some sort of data store to call up when checking supplied information.
Got it. i am going to talk with my server administrator to see if he can create a database for me and add me as an admin to the database or if he can create a seperate table for me in the existing database. Validation is the most important thing. Everah looks like you love this php and mysql. you are great and you have provided alot of information to me in order to complete my task. Thankyou so much have a great day.
p.s: i am doing my final project for CS (creating an online testing tool where students can take the test, track the test scores and view the test scores).
Take care
p.s: i am doing my final project for CS (creating an online testing tool where students can take the test, track the test scores and view the test scores).
Take care
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA