jeaker Posted October 25, 2006 Share Posted October 25, 2006 I am attempting to get get this script to now e-mail the user everything that was already printed out to the screen.The output is a series of last names first names and the GPA. I would like that all to be email to the user. I think i am pretty close with this script but cannot figure out how to get the whole thing to be emailed.Any help is greatly appreciated. ???<?php$to = "$_POST[user_email]";$subject = "Grades";$headers = "From: The PHP Master.";mail($to, $subject, $headers, $line);?><html><head><title>Mailing Data From a File</title></head><body><?php$line = file("Grades.txt");$i = 0;$num = 0;$cnt = 0;while ($line[$i] != -2) { $first = $line[$i]; $i++; $last = $line[$i]; $i++; while ($line[$i] != -1) { $num = $num + $line[$i]; $cnt++; $i++; }$num = $cnt > 0 ? $num / $cnt : 0;echo "$last, $first, $num<br />";$i++;$cnt = 0;$num = 0;}?></body></html>[table][tr][td][/table] Quote Link to comment Share on other sites More sharing options...
jwk811 Posted October 26, 2006 Share Posted October 26, 2006 ummm im guessing that the line variable is the message right? in the mail function you need it to be, to email address, subject, message, headers.. you have it mixed up a little.. if $line is the message the email function in your script should look like this..[code]<?php$email = $_POST[user_email];$to = "$email";$subject = "Grades";$headers = "From: The PHP Master.";mail($to, $subject, $line, $headers);?>[/code]ahh if your trying to send all that html stuff in the email then im not sure how to do that.. hope this still helps you though cause i think you were sending the mail the wrong way.. im pretty sure it matters lol Quote Link to comment Share on other sites More sharing options...
marcus Posted October 26, 2006 Share Posted October 26, 2006 you need to define $line before you use it first.[code]<html><head><title>Mailing Data From a File</title></head><body><?php$line = file("Grades.txt");$i = 0;$num = 0;$cnt = 0;while ($line[$i] != -2) { $first = $line[$i]; $i++; $last = $line[$i]; $i++; while ($line[$i] != -1) { $num = $num + $line[$i]; $cnt++; $i++; }$num = $cnt > 0 ? $num / $cnt : 0;echo "$last, $first, $num";$i++;$cnt = 0;$num = 0;}?><?php$email = $_POST[user_email];$to = "$email";$subject = "Grades";$headers = "From: The PHP Master <youremail>";mail($to, $subject, $line, $headers);?></body></html>[/code] Quote Link to comment Share on other sites More sharing options...
jeaker Posted October 26, 2006 Author Share Posted October 26, 2006 I have tried using this code below(taking the above advice)...everything prints out ok to the screen but the e-mail that i receive is always blank. I cannot for the life of me figure out why?? Any thoughts???Thank you both for the help.<?php$email = $_POST[user_email];$to = "$email";$subject = "Grades";$headers = "From: The PHP Master.";mail($to, $subject, $line, $headers);?><html><head><title>Mailing Data From a File</title></head><body><?php$line = file("Grades.txt");$i = 0;$num = 0;$cnt = 0;while ($line[$i] != -2) { $first = $line[$i]; $i++; $last = $line[$i]; $i++; while ($line[$i] != -1) { $num = $num + $line[$i]; $cnt++; $i++; }$num = $cnt > 0 ? $num / $cnt : 0;echo "$last, $first, $num<br />";$i++;$cnt = 0;$num = 0;}?></body></html> 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.