0

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>";
?>

3 Answers 3

2

If you change this line:

'<input type="hidden" name="$frompage" value="$frompage">'

into this:

'<input type="hidden" name="frompage" value="$frompage">'

when the user send the data, you can retrieve it using:

$_POST['frompage']
Sign up to request clarification or add additional context in comments.

Comments

1

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>

Comments

0

First your using too much echos :P this is how I would do it.

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

When you use echo ''; The single quotes forces everything to be read exactly as it stated. If you REALLY wanted to echo all that html, use double quotes. Such as echo "Hello $frompage";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.