JamesThePanda Posted May 23, 2008 Share Posted May 23, 2008 Hi Basically I have a login script, and I need the user name and password to be sent to 2 different places. at the moment the username and password are sent to "self" the actualy action is this action = "<?php echo $PHP_SELF; ?>?subscription=<?php echo $subscription; ?>" I need it to go to this and also a file other.php Any ideas on how I would achieve this. Thanks James Quote Link to comment Share on other sites More sharing options...
unidox Posted May 23, 2008 Share Posted May 23, 2008 Why do you need it to send to 2? Quote Link to comment Share on other sites More sharing options...
JamesThePanda Posted May 23, 2008 Author Share Posted May 23, 2008 Basically its a members area. The second script is to log the users into a chat area, so they can user other names. the second script automatically sets the cookie and also lets the other server know. Thanks James Quote Link to comment Share on other sites More sharing options...
unidox Posted May 23, 2008 Share Posted May 23, 2008 Then after the 1st script is executed why dont you redirect the user and use get. Quote Link to comment Share on other sites More sharing options...
JamesThePanda Posted May 23, 2008 Author Share Posted May 23, 2008 how do I do that? Quote Link to comment Share on other sites More sharing options...
unidox Posted May 23, 2008 Share Posted May 23, 2008 can I see your code? Quote Link to comment Share on other sites More sharing options...
JamesThePanda Posted May 23, 2008 Author Share Posted May 23, 2008 Ok here is the form script <style>BODY{font-family: Verdana; font-size: 9px; color: #666666; margin: 0px; }*{ font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }</style> <?php //--------------------------------------------------------- iPHPAuthorize v1.0 by IDS - www.idevspot.com $SQL = "SELECT * from SETTINGS"; $result = mysql_query( $SQL ); $row = mysql_fetch_array( $result ); $sender = $row['EMAIL']; $action = $_GET['action']; $t_ = 'MEMBERS'; $u_ = 'USERNAME'; $p_ = 'PASSWORD'; //--------------------------------------------------------- mysql_query ("CREATE TABLE IF NOT EXISTS `MEMBERS` (`ID` INT NOT NULL AUTO_INCREMENT , `USERNAME` varchar(255) NOT NULL, `PASSWORD` varchar(255) NOT NULL, `STATUS` varchar(255) NOT NULL, `SUBSCRIPTION` varchar(255) NOT NULL, PRIMARY KEY ( `id` ) )") or die (mysql_error()); //--------------------------------------------------------- if ($action == logout) { session_start(); session_unset(); session_destroy(); } //--------------------------------------------------------- if ($action == lostpassword) { $a = $_POST['1']; if (empty($a)) {$message = 'Error : Field cannot be blank'; } else { $SQL = "SELECT * from $t_ WHERE $u_ = '$a'"; $result = mysql_query( $SQL ); while( $row = mysql_fetch_array( $result ) ) { $Xuser = $row["$u_"]; $subscription = $row["SUBSCRIPTION"]; $Xpass = $row["$p_"]; $to="$a"; $headers.= "MIME-Version: 1.0\r\n"; $headers.= "Content-type: text/html; "; $headers.= "charset=iso-8859-1\r\n"; $headers.= "From: $sender"; $subject = "Lost password recovery for subscription ID : $subscription"; $body = "Your log in details : [ Username : $Xuser ] [ Password : $Xpass ]"; mail($to,$subject,$body,$headers); $message = 'Password sent, please check your email'; } } if (empty($Xuser)) {$message = 'Error : Username not found';} } //--------------------------------------------------------- $Zuser = $_SESSION['username']; $Zpass = $_SESSION['password']; if (empty($Zuser)) $Zuser = '0-0-0-n-u-l-l-0-0-0'; $ZuserZpass = "$Zuser$Zpass"; $SQL = "SELECT * from $t_ WHERE $u_ = '$Zuser' AND SUBSCRIPTION = '$subscription' AND STATUS != 'Ended'"; $result = mysql_query( $SQL ); while( $row = mysql_fetch_array( $result ) ) { $Auser = $row["$u_"]; $Apass = $row["$p_"]; } $AuserApass = "$Auser$Apass"; if ($ZuserZpass == $AuserApass) {} else { $a = $_POST['1']; $b = $_POST['2']; $ab = "$a$b"; $SQL = "SELECT * from $t_ WHERE $u_ = '$a' AND SUBSCRIPTION = '$subscription' AND STATUS != 'Ended'"; $result = mysql_query( $SQL ); while( $row = mysql_fetch_array( $result ) ) { $user = $row["$u_"]; $pass = $row["$p_"]; } $userpass = "$user$pass"; if ($ab == $userpass) { $_SESSION['username'] = "$user"; $_SESSION['password'] = "$pass"; $Zuser = $_SESSION['username']; $Zpass = $_SESSION['password']; }else { $subscription = $_GET['subscription']; ?> <table width="30%" border="0" cellspacing="5" cellpadding="0" align="center"> <tr> <td nowrap><b> Log In</b></td> <td background="<?php echo $row[$PATH]; ?>i_01.jpg" width="100%" height="29"> </td> </tr> </table> <table width="30%" border="0" cellspacing="5" cellpadding="0" align="center"> <tr valign="top"> <td width="50%"> <form name="form1" method="post" action="<?php echo $PHP_SELF; ?>?subscription=<?php echo $subscription; ?>"> <div align="center"><b>Paypal email address :</b><br> <input type="text" name="1" size="25" value="<?php echo $_GET[qun]; ?>"> <br> <br> <b>Subscription password : </b><br> <input type="password" name="2" size="25" value="<?php echo $_GET[qpw]; ?>"> <br> <br> <input type="submit" name="Submit" value="Sign In"> </div> </form> </td> </tr> </table> <table width="30%" border="0" cellspacing="5" cellpadding="0" align="center"> <tr> <td nowrap><b> Lost Password?</b></td> <td background="<?php echo $row[$PATH]; ?>i_01.jpg" width="100%" height="29"> </td> </tr> </table> <table width="30%" border="0" cellspacing="5" cellpadding="0" align="center"> <tr valign="top"> <td width="50%"> <form name="form1" method="post" action="<?php echo $PHP_SELF; ?>?action=lostpassword"> <div align="center"><b>Paypal email address :</b><br> <input type="text" name="1" size="25"> <br> <br> <input type="submit" name="Submit" value="Send"> </div> </form> </td> </tr> </table> <div align="center"> <?php echo $message; ?> </div> <table width="30%" border="0" cellspacing="5" cellpadding="0" align="center"> <tr> <td background="<?php echo $row[$PATH]; ?>i_01.jpg" width="100%" height="29"> </td> </tr> </table> </body> </html> <?php die();}} ?> and here is the script I am trying to link it with, i was thinking I could put this script into the other one. <?php /***************************************************************************************************** * user_create API example * Connects to our gateway and creates user if not already in our database * Place this on your login.php page right after verification of username & password in your database *****************************************************************************************************/ $member_user = 'testuser'; //user you want to create, 4-16 chars a-zA-Z0-9, get from $_POST[] $member_pass = 'testpassword'; //password for this user, 6-16 chars a-zA-Z0-9, get from $_POST[] /****************************************************************************************************/ include('global.php'); $setCookies = false; $params = '&action=user_info_request'; $params .= '&account_id='.$account_id; $params .= '&gateway_pass='.$gateway_pass; $params .= '&user='.$member_user; $result = sendPost($gateway_ip,$params,true);//use ssl // Check if user already is in our database if(stristr($result['message'],'error:Username Not Found')){ // Not found so create this user $params = '&action=user_create'; $params .= '&account_id='.$account_id; $params .= '&gateway_pass='.$gateway_pass; $params .= '&user='.$member_user; $params .= '&pass='.$member_pass; $result = sendPost($gateway_ip,$params,true);//use ssl if(stristr($result['message'],'ok:User Created')){//user created $setCoookies = true; } // Check user and pass }else if($result['user'] == $member_user){ if($result['pass'] == $member_pass){ $setCookies = true;//already in our database }else{//password needs updating $params = '&action=user_update'; $params .= '&account_id='.$account_id; $params .= '&gateway_pass='.$gateway_pass; $params .= '&user='.$member_user; $params .= '&pass='.$member_pass; $result = sendPost($gateway_ip,$params,true); //use ssl if(stristr($result['message'],'ok:User Updated')){ $setCookies = true; } } } if($setCookies){ setcookie('account_id',$account_id,0,'/'); setcookie('gateway_ip',$gateway_ip,0,'/'); setcookie('member_user',$member_user,0,'/'); setcookie('member_pass',$member_pass,0,'/'); }else{ //unknown error, handle somehow } //print_r($result); ?> What your ideas? Thanks James Quote Link to comment Share on other sites More sharing options...
JamesThePanda Posted May 23, 2008 Author Share Posted May 23, 2008 Anyone ? Quote Link to comment Share on other sites More sharing options...
mattal999 Posted May 23, 2008 Share Posted May 23, 2008 after: $Zuser = $_SESSION['username']; $Zpass = $_SESSION['password']; ADD: $Zuser = $_SESSION['username']; $Zpass = $_SESSION['password']; header("Location: THE 2ND FILE IT NEEDS TO GO TO"); Quote Link to comment Share on other sites More sharing options...
JamesThePanda Posted May 23, 2008 Author Share Posted May 23, 2008 Hey mattal thanks you soo much for you reply what does the header tag do? also should I put header("other.php"); or header("Location: other.php"); thanks James Quote Link to comment Share on other sites More sharing options...
mattal999 Posted May 23, 2008 Share Posted May 23, 2008 its basically PHP's version of JS's header.location = ""; It redirects the user to another page. and in answer to your question, use: header("Location: other.php"); Quote Link to comment Share on other sites More sharing options...
JamesThePanda Posted May 23, 2008 Author Share Posted May 23, 2008 Hey thanks for your help So with that submit the username and password to that page as well? Thanks James Quote Link to comment Share on other sites More sharing options...
mattal999 Posted May 23, 2008 Share Posted May 23, 2008 i guess so, if thats how your script works. if it uses $_GET, then it would be: other.php?user=$ZUser&pass=$ZPass Then you would pick that up in the next page: $username = $_GET['user']; $password = $_GET['pass']; Quote Link to comment Share on other sites More sharing options...
JamesThePanda Posted May 23, 2008 Author Share Posted May 23, 2008 WOOOOOHOOOOO OK I ll try that out and let you know Thanks James Quote Link to comment Share on other sites More sharing options...
JamesThePanda Posted May 23, 2008 Author Share Posted May 23, 2008 Hey One question, the form's method is POST shouldn't I use $_POST? why is the get method used when submiting to other.php Quote Link to comment Share on other sites More sharing options...
phpzone Posted May 24, 2008 Share Posted May 24, 2008 does the other chat script have a login function you could call with the parameters received from your script? is this chat script you have written or something like PHPBB? just wondering as I've done similar with phpbb before and i think i created a wrapper class that called it's login functions to start the users bulletin board session directly based on their username/pass on our main site, i needed to make sure the username/password in both databases were synchronised. if its something you wrote, forget I said anything it's late and i'm waffling. Quote Link to comment Share on other sites More sharing options...
mattal999 Posted May 24, 2008 Share Posted May 24, 2008 you use $_GET because forms are the only method of post, so you would have to have another button going to the next page with hidden inputs containing the already submitted username and password. Using get means that you can add them to the address so it immediately goes onto the next page without the need of another form. I hope this helps. Quote Link to comment Share on other sites More sharing options...
JamesThePanda Posted May 27, 2008 Author Share Posted May 27, 2008 Hey I tried it and this is what I got at the top of the page "Warning: Cannot modify header information - headers already sent by (output started at /home/touchho/public_html/members/inc_config.php:3) in /home/touchho/public_html/members/authorize.php on line 59" Any ideas James Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.