identitycrisis Posted August 11, 2009 Share Posted August 11, 2009 i am trying to modify the Post variable sent to a script..I just want to add @domain.com to the username.. Here is my script <?php if($_POST['domain'] && $_POST['username'] && $_POST['pass'] && !($_GET['failed'] == "1")) { $port = $_POST['port']; switch($port) { case '2095': // Webmail $protocol = 'http://'; break; case '2096': // Secure Webmail $protocol = 'https://'; break; } // Build the URL $redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$_POST['username'].$dom.'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl']; header ("Location: ".$redirectlocation); // Send URL } else { $error = 1; header ("Location: ".$_POST['failurl']); // Send URL if all neede information is not provided } ?> i added $POST_['username'] .= "@domain.com"; but it dint work and i also tried copying it to a new variable and modifying it ...it dint work out too Link to comment https://forums.phpfreaks.com/topic/169798-solved-modify-post-variable/ Share on other sites More sharing options...
wildteen88 Posted August 11, 2009 Share Posted August 11, 2009 $username = $_POST['username'] . '@domain.com'; $redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$username.'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl']; Link to comment https://forums.phpfreaks.com/topic/169798-solved-modify-post-variable/#findComment-895770 Share on other sites More sharing options...
identitycrisis Posted August 11, 2009 Author Share Posted August 11, 2009 ive tried it before...Not working ...Unable to figure out the fault... ok is there a way so that i can modify it before sending it to script... <form action="login.php" method="POST"> <?php if(($_GET['failed'] == "1") or ($error == 1)){ echo '<font color="#FF0000">login attempt failed!</font><br />'; } ?> Domain: <input type="hidden" name="domain" value="domain.com"/><br /> Username: <input type="text" name="username" value="" size="20" /><br /> Password: <input type="password" name="pass" value="" size="20" /><br /> <?php // This failurl allows cPanel to redirect back to this site echo '<input type="hidden" name="failurl" value="http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?failed=1">'; ?> Options: <select name="port"> <option value="2095">Webmail</option> <option value="2096">Secure Webmail</option> </select><br /> <input type="submit" value="Login" /> </form> Link to comment https://forums.phpfreaks.com/topic/169798-solved-modify-post-variable/#findComment-895781 Share on other sites More sharing options...
wildteen88 Posted August 11, 2009 Share Posted August 11, 2009 It should do. What does the generated url look like? Change $username = $_POST['username'] . '@domain.com'; $redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$username.'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl']; to $username = $_POST['username'] . '@domain.com'; $redirectlocation = $protocol.$_POST['domain'].':'.$port.'/login/?user='.$username.'&pass='.$_POST['pass'].'&failurl='.$_POST['failurl']; echo $redirectlocation; exit; Is the url formatted correctly? Link to comment https://forums.phpfreaks.com/topic/169798-solved-modify-post-variable/#findComment-895783 Share on other sites More sharing options...
identitycrisis Posted August 11, 2009 Author Share Posted August 11, 2009 that was the silly mistake i could ever do ....Ive been checking that on a local server,where in the form action was wrt to login script on the server Thank you so much... Link to comment https://forums.phpfreaks.com/topic/169798-solved-modify-post-variable/#findComment-895803 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.