Jump to content

[SOLVED] Modify Post variable


identitycrisis

Recommended Posts

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

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>

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.