[
Scusa ma la pagina a cui voglio essere reindirizzato deve essere x forza in php?Non puo' essere una cosa tipo areaprotetta.htm?Potresti anche indicarmi do eseguire le modifiche,chiamando appunto la mia pagina areaprotetta.htm(o php se proprio non se ne puo' fare a meno...)
Allego script:(grazie di tutto)
Codice PHP:
<?PHP
include ("functions.php");
// the Default function.
//note for functions: if you want to include a value of some variables inside the funtions,
//then you have to GLOBAL it first.
function index($user) {
global $db, $prefix;
//check if the user is logged in or not.
if (is_logged_in($user)) {
include("header.php");
//get_my_info($user);
$cookie_read = explode("|", base64_decode($user));
//define variables to hold cookie values.
$userid = $cookie_read[0];
$username = $cookie_read[1];
$password = $cookie_read[2];
$ipaddress = $cookie_read[3];
$lastlogin_date = $cookie_read[4];
$lastlogin_time = $cookie_read[5];
if($ipaddress == "") $ipaddress = ""._NOT_YET."";
//print wilcome message
echo ""._WELCOME." <b>$username</b>, "._LAST_LOGIN." "._FROM.": [$ipaddress] "._ON." [$lastlogin_date @ $lastlogin_time] (<a href=users.php?maa=Logout>"._LOGOUT."</a>)";
echo "<br><br><br><br>";
navigation_menu();
include("footer.php");
}else{
//if the user is not logged in then show the login form.
// header("Location: users.php?maa=Login"); die();
include("header.php");
login_form();
include("footer.php");
}
}
################################################################################
#------------------------------------------------------------------------------#
# navigation menu
#------------------------------------------------------------------------------#
################################################################################
function navigation_menu(){
echo " <center>"
." [ <a href=\"index.php\">"._HOME."</a> ] "
." [ <a href=\"users.php\">"._MY_ACCOUNT."</a> ] "
." [ <a href=\"users.php?maa=EditMyInfo\">"._CHANGE_MY_INFO."</a> ]"
." [ <a href=\"users.php?maa=ChangePWD\">"._CHANGE_MY_PASSWORD."</a> ]"
." [ <a href=\"users.php?maa=Logout\">"._LOGOUT."</a> ]"
." </center><br>";
}
################################################################################
#------------------------------------------------------------------------------#
# login
#------------------------------------------------------------------------------#
################################################################################
//the login form
// in this form there is hidden field (<input type=\"hidden\" name=\"maa\" value=\"do_login\">)
//this used to do the login process
function login_form(){
global $username,$user_err,$pass_err,$error_msg;
echo "<center><font class=\"title\">"._PLEASE_ENTER_YOUR_USER."</font></center>\n";
echo "
<center>
<form method=\"POST\" action=\"users.php\" name=\"loginform\">
<table border=\"0\" cellspacing=\"2\" cellpadding=\"4\">
<tr>
<td bgcolor=\"#E2E2E2\">"._USERNAME." : </td>
<td bgcolor=\"#E2E2E2\"><input type=\"text\" name=\"username\" value=\"$username\" size=\"11\"> $user_err</td>
</tr>
<tr>
<td bgcolor=\"#E2E2E2\">"._PASSWORD." : </td>
<td bgcolor=\"#E2E2E2\"><input type=\"password\" name=\"password\" size=\"11\"> $pass_err</td>
</tr>
<tr>
<td colspan=2>"._REMEBER_ME." <input type=\"checkbox\" name=\"remember\" value=\"ON\"></td>
</tr>
<tr>
<td> </td>
<td> <input type=\"hidden\" name=\"maa\" value=\"do_login\">
<input type=\"submit\" value=\""._LOGIN."\"></p>
</td>
</tr>
</table> $error_msg
</form>[<a href=\"index.php\">"._HOME."</a>] [ <a href=\"users.php?maa=Register\">"._REGISTER."</a> <img src=\"http://forum.it.altervista.org/images/register.gif\"> ] [ <a href=\"users.php?maa=Forgot_pwd\">"._FORGOT_PASSWORD."</a> <img src=\"http://forum.it.altervista.org/images/forgot_pwd.gif\"> ]<br><br>";
}
//a login function to call the login form.
function Login(){
include("header.php");
login_form();
include("footer.php");
}
//this function will do the login porcess for you.
function do_login(){
// define the values from the form.
//note for functions: if you want to include a value of some variables inside the funtions,
//then you have to GLOBAL it first.
global $prefix,$db,$username,$password, $remember, $user_err,$pass_err,$error_msg,$REMOTE_ADDR;
//check username and password fields.
if((!$username) || (!$password)){
include("header.php");
$reqmsg= "(<font class=\"error\">"._REQUIRED."</font>)";
if(trim(empty($username))){
$user_err= $reqmsg;
}
if(empty($password)){
$pass_err= $reqmsg;
}
//load the login form again.
login_form();
include("footer.php");
exit();
}
##--nothing empty? lets do the login
//encyrpt password for more Security
$md5_pass = md5($password);
$sql = $db->sql_query("SELECT * FROM ".$prefix."_users WHERE username='$username' AND password='$md5_pass'");
$login_check = $db->sql_numrows($sql);
///////////////////////////////////////////////////////////////////////
//if the entered informations are correct, then login and create the cookies.
if($login_check > 0){
while($row = $db->sql_fetchrow($sql)){
$userid = $row['userid'];
$username = $row['username'];
$password = $row['password'];
$ipaddress = $row['ipaddress'];
$lastlogin = explode(" ", $row['lastlogin']);
$lastlogin_date = $lastlogin[0];
$lastlogin_time = $lastlogin[1];
$info = base64_encode("$userid|$username|$password|$ipaddress|$lastlogin_date|$lastlogin_time");
if (isset($remember)){
setcookie("user","$info",time()+1209600);
}else{
setcookie("user","$info",0);
}
$db->sql_query("UPDATE ".$prefix."_users SET ipaddress='$REMOTE_ADDR', lastlogin=NOW() WHERE userid='$userid'");
//print success message and redirect browser
msg_redirect(""._LOGIN_SUCCESS."","users.php","5");
}
//if the entered informations are wrong, then print error message.
}else{
//include("header.php");
$error_msg = "<font class=\"error\">"._LOGIN_ERROR."</font>";
unset($username);
unset($password);
include("header.php");
login_form();
include("footer.php");
exit();
}
}