Hola buenas estoy empezando en esto del PHP y necesitaba para una pagina que estoy creando que cuando el cliente inserte su name y su pass pues bueno le redirija a su propia pagina.
He buscado bastante y no he encontrado nada asi que me he decidido a modificar un script que es este:
<?php
$goHere="Prueba.html"; // Page to send successfull log-ins to
$logSuccess="1"; // Track / log successful log-ins (1 = yes and 0 = no)
$namePassCombos = array ( // Add as many lines as you like below
"name1" => "pass1", // Add username and password combo here
"name2" => "pass2", // Add username and password combo here
"name3" => "pass3" // Add username and password combo here
);
// Replace bad characters in user input
$passWord = preg_replace ("/</","[",$passWord); $loginName = preg_replace ("/>/","]",$loginName);
$loginName = str_replace(".."," ",$loginName); $passWord = str_replace(".."," ",$passWord);
// Trim whitespace from user input
$loginName=trim($loginName); $passWord=trim($passWord);
// If log-in was successfull
$logInTracker="successLog.txt";
function success($logSuccess,$logInTracker,$loginName,$goHere)
{
$date=date ("l dS of F Y h:i:s A");
$register_globals = (bool) ini_get('register_gobals');
if ($register_globals) $ip = getenv(REMOTE_ADDR);
else $ip = $_SERVER['REMOTE_ADDR'];
// If webmaster wants to log successful logins
if($logSuccess=="1"){
$log=fopen("files/$logInTracker", "a+");
fputs($log, "$loginName logged in on: $date - Logged IP address: $ipn");
fclose($log);
}
// If no log or after log then go here
Header("Location: $goHere");
}
// If there is an error
function error($notice)
{
// Display error notice (0)
if($notice=="0"){
echo"
<title>Log-In Error: Absent username / password</title>
<body><br><p style="font:11pt arial"><font color=red>NOTICE:</font> Log-In Error: Absent username / password.
<br><br><br>Click <a href="javascript:history.back(1)" style="color:black">here</a> to try again.
</body></html>
"; exit;
}
// Display error notice (1)
if($notice=="1"){
echo"
<title>Log-In Error: Incorrect username / password</title>
<body><br><p style="font:11pt arial"><font color=red>NOTICE:</font> Log-In Error: Incorrect username / password.
<br><br><br>Click <a href="javascript:history.back(1)" style="color:black">here</a> to try again.
</body></html>
"; exit;
}
}
// If the user doesnt enter a name or password then set error notice to 0 and display error
if (($loginName == "") || ($passWord == "")) { $notice=0; error($notice); }
// If the username and password entered don't match then set error notice to 1 and display error
else if (strcmp($namePassCombos[$loginName],$passWord) != 0) { $notice=1; error($notice); }
// If the log in was sucessful
else if (strcmp($namePassCombos[$loginName],$passWord) == 0) { success($logSuccess,$logInTracker,$loginName,$goHere); }
$goHere="Prueba2.html"; // Page to send successfull log-ins to
$logSuccess="1"; // Track / log successful log-ins (1 = yes and 0 = no)
$namePassCombos = array ( // Add as many lines as you like below
"name4" => "pass4", // Add username and password combo here
"name5" => "pass5", // Add username and password combo here
"name6" => "pass6" // Add username and password combo here
);
// Replace bad characters in user input
$passWord = preg_replace ("/</","[",$passWord); $loginName = preg_replace ("/>/","]",$loginName);
$loginName = str_replace(".."," ",$loginName); $passWord = str_replace(".."," ",$passWord);
// Trim whitespace from user input
$loginName=trim($loginName); $passWord=trim($passWord);
// If log-in was successfull
$logInTracker="successLog.txt";
function success($logSuccess,$logInTracker,$loginName,$goHere)
{
$date=date ("l dS of F Y h:i:s A");
$register_globals = (bool) ini_get('register_gobals');
if ($register_globals) $ip = getenv(REMOTE_ADDR);
else $ip = $_SERVER['REMOTE_ADDR'];
// If webmaster wants to log successful logins
if($logSuccess=="1"){
$log=fopen("files/$logInTracker", "a+");
fputs($log, "$loginName logged in on: $date - Logged IP address: $ipn");
fclose($log);
}
// If no log or after log then go here
Header("Location: $goHere");
}
// If there is an error
function error($notice)
{
// Display error notice (0)
if($notice=="0"){
echo"
<title>Log-In Error: Absent username / password</title>
<body><br><p style="font:11pt arial"><font color=red>NOTICE:</font> Log-In Error: Absent username / password.
<br><br><br>Click <a href="javascript:history.back(1)" style="color:black">here</a> to try again.
</body></html>
"; exit;
}
// Display error notice (1)
if($notice=="1"){
echo"
<title>Log-In Error: Incorrect username / password</title>
<body><br><p style="font:11pt arial"><font color=red>NOTICE:</font> Log-In Error: Incorrect username / password.
<br><br><br>Click <a href="javascript:history.back(1)" style="color:black">here</a> to try again.
</body></html>
"; exit;
}
}
// If the user doesnt enter a name or password then set error notice to 0 and display error
if (($loginName == "") || ($passWord == "")) { $notice=0; error($notice); }
// If the username and password entered don't match then set error notice to 1 and display error
else if (strcmp($namePassCombos[$loginName],$passWord) != 0) { $notice=1; error($notice); }
// If the log in was sucessful
else if (strcmp($namePassCombos[$loginName],$passWord) == 0) { success($logSuccess,$logInTracker,$loginName,$goHere); }
?>
Lo que he echo ha sido volver a copiar el script original para crear nuevos users pero que les dirija a una web diferente, si alguien puede ayudarme lo agradeceria.
Prueba2.html asi en un momento dado crear todos los user que quieran pero solo accediendo a su web.