Click to See Complete Forum and Search --> : Need help with this script


Sparky
12-18-2002, 08:10 PM
I am using a log in script and need some help please:

This script logs in users wuth a user name and password to a spacific page. it works just fine. Hoever whn you have loged in you can save the page and go back to it any time. I have tried to stop unwanted uses from access this page by using another script to redirect them to the login page before they can view the page they want the script is called "Must Visit From".

Here is the login script I am using:
I need it to work from a log in java script here is the script it is logging in from

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="masters" && password=="master") { window.location="http://www.lcdsecurity.com/test/testpage.html"; done=1; }

if (done==0) { alert("Invalad! Username or Password !");}
}
// End -->
</SCRIPT>

Please note it woks just fine on its own. But when I use the rediret scrip on the page I want blocked using the Must Visit From script it redirects me to the login page constantly and it does not recognize the it is the referring page.

Here is the Must Visit From script I am using.
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var requiredfrom = "http://www.lcdsecurity.com/test/sample.html"; // required prev. page
if (document.referrer.indexOf(requiredfrom) == -1) {
alert("Your Access is Denied ! You must Login before you can visit this page ! " );
window.location=requiredfrom;
}
// End -->
</script>

I need the redirect scrip to be able to know that when someone loggs in they are comming from the refferd page.

I appreciate all you help.
Kind regards Larry

Sparky
12-19-2002, 03:20 PM
Thank you Dave for your help. I was hoping it would work but I guess I will have to find another way.

Kind Regards and best wishes for the New Year :confused:

Xeenslayer
12-20-2002, 03:00 AM
Um, Sparky, why would you still want a password and username if they are all visible in the script?

Sparky
12-20-2002, 10:06 AM
I use the User Name and Password so that the Foster Parents must login before they can go to the Buliten Board and Chat Room as well as search of other foster parents for help. However I have had several posts on the Buliten board from people who do not log in and just find the page. These people post porn websites on the Foster Parents Bulliten board. I know that the username and password are in the script but most people wont bother to try and find it. I had tried to place a script on the other target page and it does work called Must Visit From. However it will not work with a java login script.

Since I can not get it to work I will have to try another way to prevent unwanted and visius posts from others who are not members. THe people that are members are listed in our Mysql data base and on some pages I use PhP to retreive that information, however I am so new to PhP I do not know how to write a registration form that will put the information into the data base or a login page using PhP. Thus I am stuck trying to keep unnwanted people off sertin pages and the scripts I attemted to use looked like a half decent way to do this for now until I find a better way.

dpottier
01-28-2003, 12:15 PM
Originally posted by Sparky
that information, however I am so new to PhP I do not know how to write a registration form that will put the information into the data base or a login page using PhP. Thus I am stuck trying to keep unnwanted people off sertin pages and the scripts I attemted to use looked like a half decent way to do this for now until I find a better way. [/B]

After 10 years of HTML sites I use PhP MySQL almost exclusively for web sites these days. I would strongly suggest you check out some of the OpenSource CMS (Content Management Systems) available.

I am doing some alpha testing on a new release of one package called eNvolution. It would more than meet your needs for power, depth, budget (the software is free) and security, both current and future check out http://eNvolution.com Registration is FREE so please do so. :)

If you have questions, please ask. Only too happy to help

David

Dan Drillich
01-28-2003, 02:52 PM
Sparky,

You might consider passing a parameter in the query string to the redirected page, so you know where you came from.

Cheers,
Dan

Sparky
01-28-2003, 04:35 PM
Thanks Dan Drillich we have been looking into it and are now rebuilding in PhP. Thanks everyone for your kind help on this matter. :D

Webskater
01-28-2003, 04:49 PM
When you re-build using PHP you should be careful passing variables in the querystring - they are still visible to everyone.