Hi, i am currently making a flash header for my website, i have a login function in that header and it is connected to a php script, the problem is that i cannot get the values to pass into the flash header, my Logout function works fine without any problems but my Login doesnt, if i input the details and click login, the page does not refresh, i have to manually refresh the browser in order for it to work. Any ideas?
PHP CODE:
<?php
if (!empty($_POST['email'])) {
include_once "connect_to_mysql.php";
$email = $_POST['email'];
$pass = $_POST['pass'];
$remember = $_POST['remember']; // Added for the remember me feature
$email = strip_tags($email);
$pass = strip_tags($pass);
$email = mysql_real_escape_string($email);
$pass = mysql_real_escape_string($pass);
$email = str_replace("`", "", $email);
$pass = str_replace("`", "", $pass);
$pass = md5($pass);
//make query
$sql = mysql_query("SELECT * FROM myMembers WHERE email='$email' AND password='$pass' AND email_activated='1'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
session_register('id');
$_SESSION['id'] = $id;
$username = $row["username"];
session_register('username');
$_SESSION['username'] = $username;
$email = $row["email"];
session_register('email');
$_SESSION['email'] = $email;
mysql_query("UPDATE myMembers SET last_log_date=now() WHERE id='$id'");
$my_msg = "all_good";
print "return_msg=$my_msg&id=$id&username=$username";
} // close while
// Remember Me Section Addition... if member has chosen to be remembered in the system
if ($remember == "yes"){
setcookie("idCookie", $id, time()+60*24*60*60, "/"); // 60 days; 24 hours; 60 mins; 60secs
setcookie("usernameCookie", $username, time()+60*24*60*60, "/"); // 60 days; 24 hours; 60 mins; 60secs
setcookie("emailCookie", $email, time()+60*24*60*60, "/"); // 60 days; 24 hours; 60 mins; 60secs
setcookie("passCookie", $pass, time()+60*24*60*60, "/"); // 60 days; 24 hours; 60 mins; 60secs
}
} //close second if
else {
$my_msg = "no_good";
print "return_msg=$my_msg";
exit();
}
}// close if post
?>
AS3 CODE:
stop();
//email_txt.tabIndex = 1;
//password_txt.tabIndex = 2;
//sumbit_btn.tabIndex = 3;
////////////
// Assign a variable name for our URLVariables object
var variables:URLVariables = new URLVariables();
// Build the varSend variable
var varSend:URLRequest = new URLRequest("http://localhost/scripts/login.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
// Build the varLoader variable
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, completeHandler);
// Handler for PHP script completion and return
function completeHandler(event:Event):void{
status_txt.text = "";
if (event.target.data.return_msg == 'no_good') {
status_txt.text = "No match in our records, please try again";
} else if (event.target.data.return_msg == 'all_good') {
var reloadPage:URLRequest = new URLRequest("javascript:NewWindow=window.location.reload(); NewWindow.focus(); void(0);");
navigateToURL(reloadPage,"_self");
}
}
// Add an event listener for the submit button and what function to run
submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);
// Validate form fields and send the variables when submit button is clicked
function ValidateAndSend(event:MouseEvent):void{
// "Remember Me" addition code for the checkbox variable------------
var rememberChoice:String;
////////////////// remember me variable setup/////////////
if (rememberCheckbox.currentFrame == 2) {
rememberChoice = "yes";
} else {
rememberChoice = "no";
}
// End "Remember Me" addition code for the checkbox variable-------
status_txt.text ="";
//validate form fields
if(!email_txt.length) {
status_txt.text = "Please enter your email address.";
} else if(!password_txt.length) {
status_txt.text = "Please enter your password.";
} else {
// Ready the variables for sending
variables.email = email_txt.text;
variables.pass = password_txt.text;
variables.remember = rememberChoice; // Added for Remember me checkbox
// Send the data to the php file
varLoader.load(varSend);
status_txt.text = "Logging in...";
} // close else after form validation
} // Close ValidateAndSend function //////////////////////////////////////////////////////////////