Page 1 of 1
Simple Header code
Posted: Sat Aug 21, 2004 1:22 pm
by AliasBDI
I have this code on my login page:
Code: Select all
$sitepath = "www.domainname.com"
$domain = $_POST['domain'];
$redirect = $sitepath . "/" . $domain;
header("Location: $redirect");
I don't think I'm doing it correctly. Should this work? Basically, someone sends a form with the field "domain" which contains something like "domain.com" in it. I want it to redirect them to a url built by the variables.
Following the code above the variable redirect should read:
Should this work?
Posted: Sat Aug 21, 2004 1:31 pm
by feyd
you probably need to add a protocol to be compatible with more browsers.. (http:// or whatever...)
Sorry.
Posted: Sat Aug 21, 2004 1:34 pm
by AliasBDI
Yea I have that in the $sitepath. It reads like this instead: $sitepath = "
http://www.domainname.com";
Sorry to leave that out. But everything else should work?
Posted: Sat Aug 21, 2004 1:37 pm
by feyd
as long as "domain.com" generates a response from the server.. I don't see a problem..
Alright!
Posted: Sat Aug 21, 2004 1:50 pm
by AliasBDI
Did some twinking and got it working. Here is the code for anyone to use. It basically redirects a person after a post form of fields "domain" and "password".
Code: Select all
<?php
/* Check User Script */
session_start(); // Start Session
include 'connection_db.php';
// Convert to simple variables
$domain = $_POST['domain'];
$password = $_POST['password'];
$sitepath = "http://www.domainname.com";
if((!$domain) || (!$password)){
include 'loginAgain.php';
exit();
}
// Convert password to md5 hash
$password = md5($password);
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM user_info WHERE domain='$domain' AND password='$password' AND active='Y'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// update last login
$last_login = "UPDATE user_info SET date_lastlogin = NOW() WHERE domain = '$domain' AND password = '$password'";
mysql_query($last_login) or die(mysql_error());
// Register some session variables!
session_register('domain');
$_SESSION['domain'] = $domain;
session_register('email');
$_SESSION['email'] = $email;
session_register('level');
$_SESSION['level'] = $level;
session_register('date_created');
$_SESSION['date_created'] = $date_created;
session_register('id');
$_SESSION['id'] = $id;
session_register('password');
$_SESSION['password'] = $password;
session_register('active');
$_SESSION['active'] = $active;
$redirect = $sitepath . "/client_" . $domain;
header("Location: $redirect");
}
} else {
$msg = "You could not be logged in! Either the username and password do not match or you have not been activated! Please try again!<br />";
include 'loginAgain.php';
}
?>
Posted: Sat Aug 21, 2004 2:09 pm
by feyd
[php_man]session_register[/php_man] wrote:If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered(), and session_unregister().