segwaypirate Posted September 3, 2010 Share Posted September 3, 2010 Here is the code in question: <form method="post" action="../php/sendmail.php"> <?php function RandomLine() { $textfile = "../messages/compliments.txt"; if(file_exists($textfile)) { $compliments = file($textfile); $string = $compliments[array_rand($compliments)]; } else { $string = "Error"; } return $string; } $line = RandomLine(); echo "<p style='color: red;'>"."$line"."</p>"; ?> <br> <input type="hidden" name="email" value="[email protected]"> <input type="hidden" name="subject" value="random compliment generator"> <input type="hidden" name="message" value="$line"> <input type="hidden" name="to" value="[email protected]"> <input type="submit" name="sendtext" value="Send to phone!"> </form> And here is the php from sendmail.php: <?php $email = $_REQUEST['email']; $subject = $_REQUEST['subject']; $message = $_REQUEST['message']; $to = $_REQUEST['to']; $sent=mail($to, $subject, $message, "From: $email"); if($sent)echo "<br><p>The message was sent!</p>"; else echo "<br><p>There was an error while sending the message.</p>"; ?> When the form from the first bit of code is opened in an iframe, the echo displays the correct code but if the button is sent, the sms/email received simply says "$line". Any ideas? Link to comment https://forums.phpfreaks.com/topic/212413-php-in-an-iframe-acting-funny/ Share on other sites More sharing options...
Pikachu2000 Posted September 3, 2010 Share Posted September 3, 2010 This line <input type="hidden" name="message" value="$line"> explicitly gives the literal value '$line' to the $_REQUEST['message'] element. Change it to <input type="hidden" name="message" value="<?php echo $line; ?>"> Link to comment https://forums.phpfreaks.com/topic/212413-php-in-an-iframe-acting-funny/#findComment-1106711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.