functions.php
function mysql_prep($value) {
$magic_quotes_active = get_magic_quotes_gpc();
$new_enough_php = function_exists( “mysql_real_escape_string” );
if($new_enough_php){
if( $magic_quotes_active) { $value = stripslashes( $value ); }
$value = mysql_real_escape_string( $value );
} else {
if (!$magic_quotes_active) {$value = addslashes ( $value ); }
}
return $value;
} //this is the function that is used with “trim(mysql_prep($_POST[‘username’])”
function redirect_to ( $location ){
if($location != NULL) {
header(“Location: {$location}”);
exit;
}
}
Versions
MYSQL: 5.5.16
PHP: 5.3.8
APACHE: 2.2.21
Comments
I used the header.php and footer.php for holding html of the page for css design and the footer closes the database connection (if it is set), as connection.php, opens it. Its not that this script is not logging me in, its failing to redirect me to “index.php”, through my “redirect_to($location)” function which has worked for me, which is an indication that the login was successful. It does create a PHPSESSID im just wondering if this is a good login script. I’ve been researching login scripts and picked functions from each that I thought would work well for me and also I have put into use strlen to make sure that the $username or $password isnt > than the value set. Am I doing everything right, using these functions right? Seems like it to me but I need to know from all the experts or professionals out there or if you have any input about improvements I can make as well. I thank you and thank you all for this forum and the help that you give us. If you are confused I am wondering if anything looks like it won’t work the way it is intended? I have made 3 versions of a login script and it is just working funny like not redirecting me to “index.php”.
Thank you all for your time and this helpful php community.