coop Posted September 4, 2007 Share Posted September 4, 2007 Hi all, I'm developing a shopping cart application using php/MySQL and a flash front end but I'm syure the information I'm looking for would e the same if it was html. I wanted to capture the Customer_id of a customers table when people login, so when people login in successfully there customer_id will be captured and sent back to flash (if I can work out how to echo the result I can send it back to flash) //Call the functions if(isset($_POST["action"])){ switch($_POST["action"]){ case "login": $result = login($_POST['username'],$_POST['pass']); echo "user=" . $result; break; case "register": $result = register($_POST['username'],$_POST['pass'],$_POST['email']); echo $result; break; case "new_password": $result = new_password($_POST['email']); echo $result; break; } } // //Login function login($username,$pass){ GLOBAL $db,$table; $username = trim($username); $pass = md5(trim($pass)); $query = mysql_query("SELECT * FROM $table WHERE userName = '$username' AND userPassword = '$pass'"); $id_query = mysql_query("SELECT userID FROM $table WHERE userName = '$username' AND userPassword = '$pass'");// My attempt to capture the id return mysql_num_rows($query); // capture the customer_id } Link to comment https://forums.phpfreaks.com/topic/67868-capture-customer_id-from-login/ Share on other sites More sharing options...
watthehell Posted September 4, 2007 Share Posted September 4, 2007 to get the variable in flash you must add a '&' before the variable in PHP echo "&var1=".$blah1."&var2=".$blah2; in flash keep a dynamic text box and name the variable &var1 this worked for me.. Link to comment https://forums.phpfreaks.com/topic/67868-capture-customer_id-from-login/#findComment-341154 Share on other sites More sharing options...
coop Posted September 4, 2007 Author Share Posted September 4, 2007 I tried this but no luck, and now the user variable isn't being passed. Is this the correct way tto capture the userid and then pass it ut of the function ? // //Call the functions if(isset($_POST["action"])){ switch($_POST["action"]){ case "login": $result = login($_POST['username'],$_POST['pass']); //echo "user=" . $result; echo "&user=" . $result . "&custID" . $cust_id; break; case "register": $result = register($_POST['username'],$_POST['pass'],$_POST['email']); echo $result; break; case "new_password": $result = new_password($_POST['email']); echo $result; break; } } // //Login function login($username,$pass){ GLOBAL $db,$table; $username = trim($username); $pass = md5(trim($pass)); $query = mysql_query("SELECT * FROM $table WHERE userName = '$username' AND userPassword = '$pass'"); $cust_id = mysql_query("SELECT userID FROM $table WHERE userName = '$username' AND userPassword = '$pass'"); return mysql_num_rows($query); return $cust_id; } Link to comment https://forums.phpfreaks.com/topic/67868-capture-customer_id-from-login/#findComment-341195 Share on other sites More sharing options...
ToonMariner Posted September 4, 2007 Share Posted September 4, 2007 you have already retrieved the data you want with the first query... <?php function login($username,$pass){ GLOBAL $db,$table; $username = trim($username); $pass = md5(trim($pass)); $query = mysql_query("SELECT * FROM $table WHERE userName = '$username' AND userPassword = '$pass'"); if (mysql_num_rows($query) == 1) { $data = mysql_fetch_assoc($query); return $data['userID']; } else { return false; } } ?> Link to comment https://forums.phpfreaks.com/topic/67868-capture-customer_id-from-login/#findComment-341201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.