aggieerin Posted December 7, 2008 Share Posted December 7, 2008 Howdy all, My background is in perl, so I get most of what's going on with PHP. I have a set of code that is a "game" that runs both javascript and php. It's actually a psychology experiment I am trying to run. Here's how it works: People log in to the website and take the "game" (which can be seen http://www.olemiss.edu/depts/psychology/exp/ospan/ospan.html here). If you want to try it (I would not recommend this) the codes are p1, p2, p3...up to p180. The javascript randomizes the screens and what you see in different orders (don't know if you need to know this or not, but can't hurt). After they are done with the game, it form posts to "ospanlog.php". The original ospanlog.php had all the write handles to open a text file and write it to the server. I know the post action is working because otherwise it would give you an error and you would not see the end game screen. The tech guys that set up my web space swear I have write permissions to my folders, but I have yet to believe them since this file will not work. If you set up your own websever (such as IBserver) the damn thing works fine. My solution to this is just to get the form to email me the information. However, I am doing something wrong because my basic grasp of the mail function in PHP is not sending me an email. I'm hoping that y'all can tell me what I'm doing wrong. Here's the original code: <? if($endGameField) { $allstring = "******************OVERALL DATA FOR $id******************\n"; $allstring .= "Test Date: " . date("m/d/Y") . "\n"; $allstring .= "Test Time: " . date("h:i:s") . "\n"; $allstring .= "IP Address: " . $_SERVER['REMOTE_ADDR'] . "\n"; $allstring .= "Final math percentage: " . $mathPercentage . "\n"; $allstring .= "Total problems shown: " . $totalLetters . "\n"; $allstring .= "Total letters correct: " . $lettersCorrect . "\n"; $rawString = explode("^",$endGameField); $label = ""; $cnt = 1; $masterCnt = 1; for($i=1; $i<count($rawString); $i++) //Scip first line because it is blank { if($cnt == 13) { $cnt = 1; $masterCnt ++; } if($cnt == 1) { $allstring .= "\n******************SET $masterCnt DATA FOR $id******************\n"; $allstring .= "Maximum Math Time: " . $mathTime . "\n"; } switch($cnt) { case 1:$label = "Equations: "; break; case 2:$label = "Shown Answers: "; break; case 3:$label = "Correct Answers: "; break; case 4:$label = "Student Answers: "; break; case 5:$label = "Student Was Correct: "; break; case 6:$label = "Letters Shown: "; break; case 7:$label = "Students Letters: "; break; case 8:$label = "Time on Problem screen: "; break; case 9:$label = "Time on Answer Screen: "; break; case 10:$label = "Times on Recall screen: "; break; case 11:$label = "Session Letters Correct: "; break; case 12:$label = "Session Math Percentage: "; break; default: break; } $allstring .= $label . $rawString[$i] . "\n"; $cnt ++; } $filename = "scores/" . $id . "-OSPAN.txt"; $handle = fopen($filename, 'w+'); fwrite($handle, $allstring); fclose($handle); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> OSPAN </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY> <div style="margin-top:50px; cursor:default;"> <table width="80%" border="4" cellspacing="0" cellpadding="8" align="center" bordercolor="#000000" height="80%"> <tr> <td valign="middle" bgcolor="#CCCCCC" align="center"> <div style="font: 22pt verdana; font-weight:bold;">The game is over.<br><br> Thank you for participating.<br> <br> <br> <a href="javascript:window.close()">Close this window</a>.</div> </td> </tr> </table> </div> </BODY> </HTML> Here's what I tried with no luck: <? if($endGameField) { $allstring = "******************OVERALL DATA FOR $id******************\n"; $allstring .= "Test Date: " . date("m/d/Y") . "\n"; $allstring .= "Test Time: " . date("h:i:s") . "\n"; $allstring .= "IP Address: " . $_SERVER['REMOTE_ADDR'] . "\n"; $allstring .= "Final math percentage: " . $mathPercentage . "\n"; $allstring .= "Total problems shown: " . $totalLetters . "\n"; $allstring .= "Total letters correct: " . $lettersCorrect . "\n"; $rawString = explode("^",$endGameField); $label = ""; $cnt = 1; $masterCnt = 1; for($i=1; $i<count($rawString); $i++) //Scip first line because it is blank { if($cnt == 13) { $cnt = 1; $masterCnt ++; } if($cnt == 1) { $allstring .= "\n******************SET $masterCnt DATA FOR $id******************\n"; $allstring .= "Maximum Math Time: " . $mathTime . "\n"; } switch($cnt) { case 1:$label = "Equations: "; break; case 2:$label = "Shown Answers: "; break; case 3:$label = "Correct Answers: "; break; case 4:$label = "Student Answers: "; break; case 5:$label = "Student Was Correct: "; break; case 6:$label = "Letters Shown: "; break; case 7:$label = "Students Letters: "; break; case 8:$label = "Time on Problem screen: "; break; case 9:$label = "Time on Answer Screen: "; break; case 10:$label = "Times on Recall screen: "; break; case 11:$label = "Session Letters Correct: "; break; case 12:$label = "Session Math Percentage: "; break; default: break; } $allstring .= $label . $rawString[$i] . "\n"; $cnt ++; } $to = "[email protected]"; $subject = "$id"; $message = $allstring; $headers = "From: ospansite"; mail($to, $subject, $message, $headers); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> OSPAN </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY> <div style="margin-top:50px; cursor:default;"> <table width="80%" border="4" cellspacing="0" cellpadding="8" align="center" bordercolor="#000000" height="80%"> <tr> <td valign="middle" bgcolor="#CCCCCC" align="center"> <div style="font: 22pt verdana; font-weight:bold;">The game is over.<br><br> Thank you for participating.<br> <br> <br> <a href="javascript:window.close()">Close this window</a>.</div> </td> </tr> </table> </div> </BODY> </HTML> Thanks for the help in advance. Link to comment https://forums.phpfreaks.com/topic/135869-hopefully-an-easy-php-mail-question/ Share on other sites More sharing options...
aggieerin Posted December 7, 2008 Author Share Posted December 7, 2008 ok i change the offending section to this: $to = "[email protected]"; $subject = "$id"; $message = "$allstring"; $headers = "From: [email protected]"; mail($to, $subject, $message, $headers); after reading some other posts on the board. No love. Link to comment https://forums.phpfreaks.com/topic/135869-hopefully-an-easy-php-mail-question/#findComment-708259 Share on other sites More sharing options...
chronister Posted December 7, 2008 Share Posted December 7, 2008 Check out PHPMailer. http://phpmailer.codeworxtech.com/index.php?pg=phpmailer It is a really good mail class. I used the standard mail function for a long time and struggled with somethings like attaching files, and creating a text/html email. PHPMailer made these things SUPER easy and allows for mail(), smtp, gmail and I think a couple other transport methods. There may also be something in the config for the server. I had a problem when I switched the company I worked for to a VPS. I had to add an entry to the trusted_domains file (linux server) before any mail would go through. Thats all I got on this. Nate Link to comment https://forums.phpfreaks.com/topic/135869-hopefully-an-easy-php-mail-question/#findComment-708271 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.