Search code examples
phpvariablespostform-post

PHP Post Variable


How would i get the $frompage variable to send to the page it is posting to here is what i thought:

<link rel="stylesheet" type="text/css" href="style1.css" />
<?php 
$frompage = $_SERVER['HTTP_REFERER'];
echo '<form name="form1" method="post" action="report.php">';
echo "What is Wrong?";
echo '<textarea style="resize: none;" name="message" cols="70" rows="10" id="message">        </textarea>';
echo'<input type="hidden" name="$frompage" value="$frompage">';
echo '<input type="submit" name="Submit" value="Submit">';
echo "</form>";
?>

Solution

  • Keep it simple, no need to echo all of the HTML.

    <link rel="stylesheet" type="text/css" href="style1.css" />
    <form name="form1" method="post" action="report.php">
        <label>What is Wrong?</label>
        <textarea style="resize: none;" name="message" cols="70" rows="10" id="message">        </textarea>
        <input type="hidden" name="frompage" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" />
        <input type="submit" name="Submit" value="Submit" />
    </form>