Hi,
trying to create a simple login page using php and a post form.
The following requirement holds,
1. there should NOT be any DB.
2. One user and one password is enough (yeah, said it was a simple
one...)
Tried with a function check_user() in a lib php-file, and a post form
in the login page. Code as follow:
<?php
function check_user(){
global $userfield, $pwdfield;
if( strcmp($_POST[$userfield],"user") == 0 ) {
if( strcmp($_POST[$pwdfield],"pwd") == 0 ) {
// Correct user
echo("correctdi r/album.htm");
}
else {
// Wrong pwd
echo("../somdir/default.htm");
}
else {
// wrong user
echo("../otherdir/default.htm");
}
}
}
?>
and the login page for is:
<?PHP
require('../somelib/login_lib.php') ;
?>
....
<form name="form1" method="post" action="<?php check_user();?> ">
<input type="text" name="userfield " >
<input type="password" name="pwdfield" >
<input type="submit" name="Log in" value="Log in">
</form>
....
Can't get it to work. Any good idea to resolve this? Any other more
brilliant solution instead of this?
br,
Magnus
trying to create a simple login page using php and a post form.
The following requirement holds,
1. there should NOT be any DB.
2. One user and one password is enough (yeah, said it was a simple
one...)
Tried with a function check_user() in a lib php-file, and a post form
in the login page. Code as follow:
<?php
function check_user(){
global $userfield, $pwdfield;
if( strcmp($_POST[$userfield],"user") == 0 ) {
if( strcmp($_POST[$pwdfield],"pwd") == 0 ) {
// Correct user
echo("correctdi r/album.htm");
}
else {
// Wrong pwd
echo("../somdir/default.htm");
}
else {
// wrong user
echo("../otherdir/default.htm");
}
}
}
?>
and the login page for is:
<?PHP
require('../somelib/login_lib.php') ;
?>
....
<form name="form1" method="post" action="<?php check_user();?> ">
<input type="text" name="userfield " >
<input type="password" name="pwdfield" >
<input type="submit" name="Log in" value="Log in">
</form>
....
Can't get it to work. Any good idea to resolve this? Any other more
brilliant solution instead of this?
br,
Magnus
Comment