FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Easy login in script





minty
In this script I am authenticating anyone that has the appropriate passphrase. I have it working except for the part that sends them to a different location if the passphrase is correct. The following is my code:

Code:

<?php

//ensures the form has been submitted, else displays the form
if (isset($_POST['pass']))
{
Auth_Check($_POST['pass']);
}else{
Display_Form();
}

//FUNCTIONS
//Ensures the accurate passphrase has been used and redirects to another site
function Auth_Check($pwd)
{
if ($pwd=="...."){
header("Location: /index.2.php"); //this is where it is not working...keeps bringing up a "Cannot find" error
}else{
//Displays an error message if wrong passphrase
echo "<font color=\"red\"><center>You have supplied an inaccurate passphrase</center></font>";
Display_Form();
}}

//used to display the form to login with
function Display_Form()
{
?>
<form name="login" action="index.php" method="POST">
<center>
<input type="password" name="pass">
<input type="submit" value="Login">
</center>
</form>
<?php
}
?>


Any ideas? And yes, I have ensured that I have created a file with the name index2.php in the same directory.

Thanks in advance,
-minty
Gushe
Even without any knowledge of php I think I found it Smile

In this part:
Code:
header("Location: /index.2.php")

I think the name is wrong; You cannot use dots for names.
You should rename the page to "index2" or "index-2" or something like that Wink

so it should be like this:
Code:
header("Location: /index-2.php")


I hope this solves it. Smile

~Gushe
minty
Holy crap!!! Thank you for the fresh eyes and look over. I didn't even notice that I had an extra "." in there. LOL. Sooooo simple, yet so hard!

Thx again,
-minty
Gushe
No Problemo Wink
Anytime. Smile

~Gushe
manav
dude pls use sessions or cookies as without them there wont b enough or ny security to say....
minty
manav wrote:
dude pls use sessions or cookies as without them there wont b enough or ny security to say....


I plan on using this...eventually. I am just doing the following as a right now sort of thing. BTW, I understand how to use the cookies (install a cookie upon authentication, set for a specific timeout, update timeout during activity, and remove after logout), however, I am unaware how sessions work.

Thanks,

-minty
mahirharoon
minty wrote:
In this script I am authenticating anyone that has the appropriate passphrase. I have it working except for the part that sends them to a different location if the passphrase is correct. The following is my code:

Code:

<?php

//ensures the form has been submitted, else displays the form
if (isset($_POST['pass']))
{
Auth_Check($_POST['pass']);
}else{
Display_Form();
}

//FUNCTIONS
//Ensures the accurate passphrase has been used and redirects to another site
function Auth_Check($pwd)
{
if ($pwd=="...."){
header("Location: /index.2.php"); //this is where it is not working...keeps bringing up a "Cannot find" error
}else{
//Displays an error message if wrong passphrase
echo "<font color=\"red\"><center>You have supplied an inaccurate passphrase</center></font>";
Display_Form();
}}

//used to display the form to login with
function Display_Form()
{
?>
<form name="login" action="index.php" method="POST">
<center>
<input type="password" name="pass">
<input type="submit" value="Login">
</center>
</form>
<?php
}
?>


Any ideas? And yes, I have ensured that I have created a file with the name index2.php in the same directory.

Thanks in advance,
-minty

i have a suggesion
Code:
<form name="login" action="index.php" method="GET">
<center>
<input type="password" name="pass">
<input type="submit" value="Login">
</center>
</form>

you should make another html page containing this and remove this code from the current php file
and use include feature and point to the html page
-----------------------------------------------------------------------------------------
Gushe wrote:
Even without any knowledge of php I think I found it Smile

In this part:
Code:
header("Location: /index.2.php")

I think the name is wrong; You cannot use dots for names.
You should rename the page to "index2" or "index-2" or something like that Wink

so it should be like this:
Code:
header("Location: /index-2.php")


I hope this solves it. Smile

~Gushe

i do not notice this problem in my webserver (apache)
so we can use index.2.php
Related topics
simple login script
Login Script
Login Script - PHP
news system with login for more than 1 user.
[REQ] An easy script/code
150 frih$ if you make me a login script with....
Fix up a login script
Login System Tutorial Part 1 Creating Registration
Free PHP/MySQL login script
Frih$ on offer for PHP Login System
problem with login script
PHP login script problem
Servlet Basic login script?
Simple PHP Login Script
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.