<?php
/* How many VARS do we need in our form */
define("NUMBER_VARS""15");
if (isset(
$_POST['tosend']))
{
    echo 
"<b>Parsing...</b><br>";
    
flush();
    
    
/* No control of data in vars here because we wan't to be free for injection etc... */
    
$url $_POST['destination'];
    
$nbused 0;
    
$tabvar = array();
    
$tabval = array();
    
$idxtab 0;
    for (
$i 0$i NUMBER_VARS$i++)
    {
        if(
$_POST['v'.$i] != "")
        {
            
$nbused++;
            
$tabvar[$idxtab] = $_POST['v'.$i];
            
$tabval[$idxtab] = $_POST['val'.$i];
            
$idxtab++;
        }
    }
    echo 
"<b>$nbused var(s) will be sent</b><br>";
    
flush();
    if (
$nbused 0)
    {
        
$fields "";
        for (
$i 0$i $nbused$i++)
        {
            
$fields .= $tabvar[$i]."=".$tabval[$i];
            if (
$nbused != && ($i+1) < $nbused)
                
$fields .= "&";
        }
        echo 
"Fields=<b>[</b>$fields<b>]</b><br>";
        
flush();
        echo 
"<b>Starting posting...</b><br>";
        
flush();
        
$data null;
        
$ch curl_init();
        
curl_setopt($chCURLOPT_URL,"$url");
        
curl_setopt($chCURLOPT_POST1);
        
curl_setopt($chCURLOPT_POSTFIELDS"$fields");
        
/* Do we need to display result ? */
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
curl_exec($ch);
        
curl_close ($ch);
        echo 
"<b>POSTED !</b><br>";
    }
}
?>
<form method="POST">
<p align='center'>POST TO THIS URL ('http://' is mandatory!):<br><input type="text" name="destination" size="80" value="http://"></p>
<table align="center" cellpadding="4">
<?php
for ($i 0$i NUMBER_VARS$i++)
{
    echo 
'<tr>';
    echo 
'<td>Variable '.$i.':</td><td><input type="text" name="v'.$i.'" size="20"></td><td>Value:</td><td><input type="text" name="val'.$i.'"></td>';
    echo 
'</tr>';
}
?>
</table>
<input type="submit" name="tosend" value="SEND!">
<input type="reset">
</form>