Page 1 of 1

Need some help

Posted: Tue Feb 13, 2007 12:36 pm
by fastmike
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.

Posted: Tue Feb 13, 2007 12:52 pm
by Kieran Huggins
BIIIIG question.. sorta like "I want to go to the store, how can I build a car that takes me there?"

You'll at least need to look into databases and sessions - try finding some tutorials on those two and maybe that will give you some direction.

Posted: Tue Feb 13, 2007 6:04 pm
by RobertGonzalez
Are you talking about taking network credentials and passing them to the web? Like logging on to a computer and having that computer know who you are and sending you where you need to go based on your network credentials?

Posted: Tue Feb 13, 2007 9:26 pm
by fastmike
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.

Posted: Tue Feb 13, 2007 11:24 pm
by RobertGonzalez
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.

Posted: Wed Feb 14, 2007 1:19 am
by fastmike
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

Posted: Wed Feb 14, 2007 1:40 am
by RobertGonzalez
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.

Posted: Wed Feb 14, 2007 9:59 am
by fastmike
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.

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();
}
?>
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

Posted: Wed Feb 14, 2007 10:31 am
by RobertGonzalez
Do you have access to a database? Or can you install one on the server if the server does not have one (which it almost certainly does).

Posted: Wed Feb 14, 2007 10:35 am
by fastmike
no everah i dont have access to the database but i am sure the guy who manages the server sshould have access to the database. say for instance if i have access then what am i suppose to do? any idea cause i dont want to go to him and feel like a dummy with knowing nothing.

Posted: Wed Feb 14, 2007 11:05 am
by RobertGonzalez
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.

Posted: Wed Feb 14, 2007 12:40 pm
by fastmike
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

Posted: Wed Feb 14, 2007 1:53 pm
by RobertGonzalez
Glad I could help. Is it that transparent that I love PHP and MySQL? :oops: