Hello Im trying to create
a php login at the current page:
Where the user will enter in their user name and password, then once submitted will take them to another page.
The page which the user will be directed to is run off site from myself. The user name will be checked with a database that he has and if the users match will let the user in. I need to set up on my end a check internally on the password field which once submitted will check my listing of appropriate passwords.
I though doing something similar to the below would maybe work, but wanted to see if there was another way of doing this if anyone has any suggestions.
So basically the user name once the submit button is hit is transferred to another place where that is validated. I just need to validate the password myself and check that it matches an appropriate password.
thanks for any help provided
<?php
ob_start();
if (!isset($_SESSION))
{
session_start();
}
$user_name = strip_tags(trim($_REQUEST['user_name']));
$password = strip_tags(trim($_REQUEST['password']));
$password_one = strip_tags(trim($_REQUEST['password_one']));
$user_info = array('Ben'=>"argh", 'Wess'=>"fffff", 'Dave'=>"harry", 'Robin'=>"987654321", 'Sarah'=>"trueBlue");
// Check user_name input...
if (!empty($user_name) AND isset($user_info[$user_name]))
{
// ... and if no errors then check password...
if (!empty($password) AND !empty($password_one) AND $password==$password_one
AND $password == $user_info[$user_name])
{
print "You have logged in successfully";
}
else
{
// if errors with password, go back to login.php and display alert
$_SESSION['alert'] = "Your passwords do not match, or are incorrect";
$_SESSION['user_name'] = $user_name;
header('location: login.php');
}
}
else
{
// if errors with user_name, go back to login.php and display alert
$_SESSION['alert'] = "The user name you have entered does not exist";
$_SESSION['user_name'] = $user_name;
header('location: login.php');
}
?>
a php login at the current page:
Where the user will enter in their user name and password, then once submitted will take them to another page.
The page which the user will be directed to is run off site from myself. The user name will be checked with a database that he has and if the users match will let the user in. I need to set up on my end a check internally on the password field which once submitted will check my listing of appropriate passwords.
I though doing something similar to the below would maybe work, but wanted to see if there was another way of doing this if anyone has any suggestions.
So basically the user name once the submit button is hit is transferred to another place where that is validated. I just need to validate the password myself and check that it matches an appropriate password.
thanks for any help provided
<?php
ob_start();
if (!isset($_SESSION))
{
session_start();
}
$user_name = strip_tags(trim($_REQUEST['user_name']));
$password = strip_tags(trim($_REQUEST['password']));
$password_one = strip_tags(trim($_REQUEST['password_one']));
$user_info = array('Ben'=>"argh", 'Wess'=>"fffff", 'Dave'=>"harry", 'Robin'=>"987654321", 'Sarah'=>"trueBlue");
// Check user_name input...
if (!empty($user_name) AND isset($user_info[$user_name]))
{
// ... and if no errors then check password...
if (!empty($password) AND !empty($password_one) AND $password==$password_one
AND $password == $user_info[$user_name])
{
print "You have logged in successfully";
}
else
{
// if errors with password, go back to login.php and display alert
$_SESSION['alert'] = "Your passwords do not match, or are incorrect";
$_SESSION['user_name'] = $user_name;
header('location: login.php');
}
}
else
{
// if errors with user_name, go back to login.php and display alert
$_SESSION['alert'] = "The user name you have entered does not exist";
$_SESSION['user_name'] = $user_name;
header('location: login.php');
}
?>