blasto Posted June 21, 2010 Share Posted June 21, 2010 Hello there, I have a basic problem please help me with the following; I have a form that asks for 1- username, by a Text field 2- domain, by a SELECT field 3- password, by a TEXT field I need to concatenate username & domain fields and POST them together as a single variable to a webmail login page (php). $fullname = $username.$domain; don't get accepted by the recipient page (login failure). How can I achieve this? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Wolphie Posted June 21, 2010 Share Posted June 21, 2010 Do you mean that $fullname = $username . $domain; isn't working? If so could you please post the HTML code for the form, and the relevant part of the PHP script please. I have a feeling that the select field isn't correctly constructed. Quote Link to comment Share on other sites More sharing options...
blasto Posted June 21, 2010 Author Share Posted June 21, 2010 ok below is the sample login page. it works without concat but when I try to tie username & domain together it stops working. <html> <head><title>my login page</title></head> <body> <p> <form method="post" action="dologin.php"> <p> username: <input name="username"> <SELECT name="domain" > <OPTION value="@test1.com">test1.com</OPTION> <OPTION value="@test2.com">test2.com</OPTION> </SELECT><br> <p> password: <input name="kerio_password" type="password"><br> <p> <input type="submit" value="log in"> </form> </body> </html> <?php $domain = $_POST['domain']; $username = $_POST['username']; $kerio_username = $username . $domain; $kerio_password = $_POST['kerio_password']; ?> Quote Link to comment Share on other sites More sharing options...
TOA Posted June 21, 2010 Share Posted June 21, 2010 ok below is the sample login page. it works without concat but when I try to tie username & domain together it stops working. <html> <head><title>my login page</title></head> <body> <p> <form method="post" action="dologin.php"> <p> username: <input name="username"> <SELECT name="domain" > <OPTION value="@test1.com">test1.com</OPTION> <OPTION value="@test2.com">test2.com</OPTION> </SELECT><br> <p> password: <input name="kerio_password" type="password"><br> <p> <input type="submit" value="log in"> </form> </body> </html> <?php $domain = $_POST['domain']; $username = $_POST['username']; $kerio_username = $username . $domain; $kerio_password = $_POST['kerio_password']; ?> I noticed your not closing your inputs... like <input type="text" /> That might cause some issues. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted June 21, 2010 Share Posted June 21, 2010 Echo the $kerio_username variable, and see if it looks correct. If it isn't, post it here along with what it should end up looking like. Quote Link to comment Share on other sites More sharing options...
blasto Posted June 21, 2010 Author Share Posted June 21, 2010 If I keep the action as <form action="" method="post"> I can echo all of the variables. And I see all of them are correct. But when it comes down to posting those across the other page , things somehow get fuzzy and thus not working (login failed error occurs)??? Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 21, 2010 Share Posted June 21, 2010 It is not going to work how you apparently think it will. You have to submit the form data before you can take any action on it. It seems you expect the form fields to be concatenated because of the cade you have at the bottom of the page. Since that code takes place before the form is ever sent to the user, that code has no purpose whatsoever. You will need to concatenate the values on the page that receives the POST data. Quote Link to comment Share on other sites More sharing options...
blasto Posted June 21, 2010 Author Share Posted June 21, 2010 ok I got your point but I've done that way already. I tried to concat variables at the target page but its not working also. I think there occurs a some kind of mismatch of types between form variables and php variables. Because if I set php variable $username to form post values, I can no longer use php variable as a proper login variable. I'm stuck at this point... Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 21, 2010 Share Posted June 21, 2010 I have no clue what you are talking about. On the page that receives the form data you would simply use something like: $full_email = $_POST['username'] . $_POST['domain']; If that doesn't work, then use the folloing on the processing page to validate that the data is being received. print_r($_POST); Quote Link to comment Share on other sites More sharing options...
blasto Posted June 21, 2010 Author Share Posted June 21, 2010 well thanks for your advises but as far as I see I can not change the post variable in anyway. let me try to explain it again; login page gets the username as <input name="username" /> and sends it to dologin.php page at that dologin.php page I can not manipulate that value (concat or change it another way). what I'm trying to achive is to create a custom login page for kerio webmail interface with a domain selector. below is the dologin page if it ever helps.. <?php $kerio_username = $_POST['username'] . $_POST['domain']; // I try to change the value here at the begining but without luck so far. $x_1dq = kerio("kerio::web::PhpSession"); if ($x_1dq) { $x_1l0 = $x_1dq->getVar('kerio_mode'); if (!$x_1l0) { if ($x_1dq->getVar('x_2la') == 'internal') { $x_1l0 = 'mini'; } else { $x_1l0 = 'full'; } } if ($x_1l0 == 'mini' && $x_1dq->getVar('x_1ue') == 'yes') { $x_1l0 = 'pda'; } $x_5ve = '?'; if ($x_1l0 == 'full') { if ($x_1dq->getVar('x_2la') == 'internal') { $x_4em = 'index.php'; } else { $x_4em = 'loginCheck.php'; } } else { $x_4em = '../mini/index.php'; if ($x_1l0 == 'pda') { $x_4em .= $x_5ve . 'pda=1'; $x_5ve = '&'; } } if ($x_1dq->getVar('kerio_startFolder')) { $x_4em .= $x_5ve . 'kerio_startFolder=' . urlencode($x_1dq->getVar('kerio_startFolder')); $x_5ve = '&'; } } else { $x_4em = 'login.php?reason=failure' . ($x_1l0 == 'mini' || $x_1l0 == 'pda' ? '&mode=' . $x_1l0 : ''); } if ($x_1dq && $x_1dq->getVar('command') == 'loginAgain') { print '1'; } else { header("Location: " . $x_4em); } ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted June 21, 2010 Share Posted June 21, 2010 In the dologin.php script, make the first lines look like below, then copy the output from print_r: and kerio_username: here. <?php echo "print_r: "; print_r($_POST); $kerio_username = $_POST['username'] . $_POST['domain']; // I try to change the value here at the begining but without luck so far. echo "<br />kerio_username: :" . $kerio_username; Quote Link to comment Share on other sites More sharing options...
blasto Posted June 22, 2010 Author Share Posted June 22, 2010 well it is behaving weird.. when I create an empty dologin.php and paste the code you suggested it echoes the following print_r: Array ( [username] => serhan [domain] => @test1.com [kerio_password] => PaSsWOrd ) kerio_username: :serhan@test1.com but with the original dologin.php page the outcome is: kerio_username: : print_r: Array ( ) there is an interference at some point but I couldn't figure it out.. 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.