[I have found out what the problem is, please read the bottom for the problem]
ok this is very weird, im learning how to make me a nice flash login where you can make an account then login. Now heres whats weird, the first part (making the account) works great, I even can go to the mysql database and see that it has worked. However when I go to the login.swf, for some reason this dosnt work, so heres my scripts
Register.swf
now the registration.php
now that part works, perfectly, i can go into my database and i see a table that has
Id | username | gold | email | password |
1 | molster | 50 | email@email.com | molster |
looks perfects... now i have the following
login.swf
and the logincheck.php
it looks fine to me, but its not working for some reason... I just cant tell why...honstly knowing me, its a typo somewhere in that script, but i cant see it.
edit: ok ive been trying to figure this out on my own, and on the last php script i found out that somthing to do with the "username" is not correct.
if i take this part of the script
and change it to
it will now work..... =(
ok this is very weird, im learning how to make me a nice flash login where you can make an account then login. Now heres whats weird, the first part (making the account) works great, I even can go to the mysql database and see that it has worked. However when I go to the login.swf, for some reason this dosnt work, so heres my scripts
Register.swf
| Code: |
| var lvSend:LoadVars = new LoadVars();
var lvReceive:LoadVars = new LoadVars(); tMessage.autoSize = true; mcAge.tInput.restrict = "0-9"column in mySQL will cause an error mcRegister.onRelease = function() { var valid:Boolean = validateForm(); if(valid){ //gather information and put in loadvars object lvSend.username = mcName.tInput.text; lvSend.password = mcSurname.tInput.text; lvSend.gold = mcAge.tInput.text; lvSend.email = mcEmail.tInput.text; //send information php script for insertion into database lvSend.sendAndLoad("registration.php", lvReceive, "POST"); }else{ alert("Please complete all fields"); } }; lvReceive.onLoad = function(success:Boolean) { if (success) { if(this.result == "emailExists"){ alert("This email address already exists in the database. Please choose another"); }else if (this.result == "success") { tMessage.text = "Thank you for registering. Your password has been sent to your email address"; clearTextFields(); } else { tMessage.text = "I'm sorry there has been an error with your registration"; } } }; function validateForm():Boolean{ if(mcName.tInput.text == "" || mcSurname.tInput.text == "" || mcAge.tInput.text == "" || mcEmail.tInput.text == ""){ return false; } return true; } function clearTextFields():Void{ mcName.tInput.text = ""; mcSurname.tInput.text = ""; mcAge.tInput.text = ""; mcEmail.tInput.text = ""; } |
now the registration.php
| Code: |
|
<?php //--------------------MYSQL DETAILS ---------------------------------------// //mysql details require_once("dbDetails.php"); //------------------GATHER FORM DETAILS ---------------------------------// $username = $_POST['username']; $gold = $_POST['gold']; $email = $_POST['email']; $password = $_POST['password']; //----first check the email addres does not exist already $SQL = "SELECT * FROM members_tbl WHERE username ='".$username."'"; $rs = mysql_query($SQL,$conn); $numRows = mysql_num_rows($rs); if($numRows > 0){ echo '&result=emailExists&'; exit();//abort php script } //--------insert into database------------------------------// $insertSQL = "INSERT INTO members_tbl(username, gold, email, password) VALUES ('$username', '$gold', '$email', '$password')"; $rs = mysql_query($insertSQL,$conn); if($rs){ //send user email with password sendEmail(); echo '&result=success&'; }else{ echo '&result=failure&'; } //------------------- EMAIL FUNCTIONALITY--------------------------// function sendEmail(){ $yourname = 'yourname'; //PUT YOUR NAME HERE $youremail = 'you@yourdomain.com';//PUT YOUR EMAIL ADDRESS HERE //to user $headers = "From: $yourname <$youremail>\n"; $headers .= "Reply-To: $yourname <$youremail>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1"; //the message body $message = "Dear ".$GLOBALS['firstname'].",<p> Thank you for registering your password is ".$GLOBALS['randomPassword']."</p>"; mail($GLOBALS['email'], "Your login details", $message, $headers); } ?> |
now that part works, perfectly, i can go into my database and i see a table that has
Id | username | gold | email | password |
1 | molster | 50 | email@email.com | molster |
looks perfects... now i have the following
login.swf
| Code: |
|
var lvSend:LoadVars = new LoadVars(); var lvReceive:LoadVars = new LoadVars(); tError.autoSize = "right"; mcLogin.onRelease = function() { lvSend.username = user.text; lvSend.password = pass.text; lvSend.sendAndLoad("logincheck.php", lvReceive, "POST"); }; lvReceive.onLoad = function(success:Boolean) { if (success) { if (this.login == "success") { getURL("members.php"); } else { tError.text = "I'm sorry you did not enter valid login details"; } } else { trace("no reponse from server"); } }; |
and the logincheck.php
| Code: |
|
<?php session_start(); $username = $_POST['username']; $password = $_POST['password']; //mysqldetails require_once("dbDetails.php"); $SQL = "SELECT * FROM members_tbl WHERE username ='".$username."' AND password = '".$password."'"; $rs = mysql_query($SQL,$conn); $numRows = mysql_num_rows($rs); if($numRows > 0){ $_SESSION['loggedIn'] = true; echo '&login=success'; }else{ echo '&login=failure'; } ?> |
it looks fine to me, but its not working for some reason... I just cant tell why...honstly knowing me, its a typo somewhere in that script, but i cant see it.
edit: ok ive been trying to figure this out on my own, and on the last php script i found out that somthing to do with the "username" is not correct.
if i take this part of the script
| Code: |
| $SQL = "SELECT * FROM members_tbl WHERE username ='".$username."' AND password = '".$password."'";
|
and change it to
| Code: |
| $SQL = "SELECT * FROM members_tbl WHERE password = '".$password."'";
|
it will now work..... =(
