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@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? Quote Link to comment 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; ?>"> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.