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@email.com">
<input type="hidden" name="subject" value="random compliment generator">
<input type="hidden" name="message" value="$line">
<input type="hidden" name="to" value="5555555555@mms.uscc.net">
<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?