codieB Posted December 10, 2008 Share Posted December 10, 2008 I posted yesterday. Seems this one might be a doozy. Almost ALL of the functionality is working save one. he purpose of this code is to get people to enter information in order to receive a "key" for access to a video archive. After pushing SUBMIT, they get an automated email response providing them with the link. THIS WORKS! Plus, I get a BCC, so I know what email addresses these are going to. WHAT DOESN"T WORK is the greeting, "Congratulations (Name). Please see following code. Your help would be GREATLY appreciated. no space <?php $menu1 = "none"; $menu2 = "none"; $menu3 = "none"; ?> <?php include '../../inc/pageheadhome.inc'; ?> <body id="home" class="colSM"> <?php include '../../inc/header_home.inc'; ?> <? // This is correctly indented ?> <div id="colmain3"> <div class="col3"> <div><div> <dl> <table id="Table_01" background="FACES_register/facesVideo.jpg" width="772" height="585" border="0" cellpadding="0" cellspacing="0"> <tr valign="middle"> <td width="194" valign=""> </td> <td width="561"><table><tr><td colspan="3"><table width="543"> <tr><td width="528" height="188px"> </td> </tr> <tr><td> <?php function spamcheck($field) { //filter_var() sanitizes the e-mail //address using FILTER_SANITIZE_EMAIL $field=filter_var($field, FILTER_SANITIZE_EMAIL); //filter_var() validates the e-mail //address using FILTER_VALIDATE_EMAIL if(filter_var($field, FILTER_VALIDATE_EMAIL)) { return TRUE; } else { return FALSE; } } if (isset($_REQUEST['email'])) {//if "email" is filled out, proceed //check if the email address is invalid $mailcheck = spamcheck($_REQUEST['email']); if ($mailcheck==FALSE) { echo "Invalid input"; } else {//send email $Name = "name"; //senders name $email = "from.mycompany.com"; //senders e-mail adress $recipient = $_REQUEST['email']; //recipient $reply = "Congratulations! Video access for " .$_POST['fname']." ".$_POST['lname'].""; $mail_body = "body content"; //mail body //mail body $subject = "Video Access"; //subject $headers = "From: ". $Name . " <" . $email . ">\r\nbcc: blind@company.com\r\n"; //optional headerfields $headers .= "BCC: blindm@company.com\r\n"; mail($recipient, $subject, $mail_body, $reply, $headers); //mail command echo "<font size='3'><font color='#c61317'><strong>Thank you.</font></strong> Please check your email for the access link.</font>"; } } else {//if "email" is not filled out, display the form echo "<form method='post' action='videoAccess.php'> To gain access to the video archive, please fill out the form below.<br /><br /> First Name: <input name='fname' type='text' /><br /> Last Name: <input name='lname' type='text' /><br /> Email: <input name='email' type='text' /><br /><br /> Subject: <strong>Access to FACES archive</strong><br /><br /> <input type='submit' /> </form>"; } ?> no space Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/ Share on other sites More sharing options...
gevans Posted December 10, 2008 Share Posted December 10, 2008 try changing; mail($recipient, $subject, $mail_body, $reply, $headers); //mail command to mail($recipient, $subject, $reply, $headers); //mail command Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711594 Share on other sites More sharing options...
codieB Posted December 10, 2008 Author Share Posted December 10, 2008 Thanks for your reply, Supporter--- That didn't do it though. This is a real stumper! Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711598 Share on other sites More sharing options...
Yesideez Posted December 10, 2008 Share Posted December 10, 2008 It didn't do it - did it return an error or just not send the mail - more info please? Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711600 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 $reply = "Congratulations! Video access for " .$_REQUEST['fname']." ".$_REQUEST['lname'].""; See if that works. If not your form is not populating/sending those values. Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711601 Share on other sites More sharing options...
codieB Posted December 10, 2008 Author Share Posted December 10, 2008 There was no error message. It just continued to send the email with everything EXCEPT the NAMES. Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711603 Share on other sites More sharing options...
codieB Posted December 10, 2008 Author Share Posted December 10, 2008 Hi Supporter, It is still doing the same thing without an error message. What did you mean by "If not your form is not populating/sending those values."? Do you know why? Is there a solution? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711606 Share on other sites More sharing options...
Yesideez Posted December 10, 2008 Share Posted December 10, 2008 The PHP mail command: http://uk.php.net/manual/en/function.mail.php The fifth parameter is for additional headers. $subject = "Video Access"; //subject $headers = "From: ". $Name . " <" . $email . ">\r\n"; //bcc: blind@company.com\r\n"; //optional headerfields //$headers .= "BCC: blindm@company.com\r\n"; mail($recipient, $subject, $mail_body, $headers); //mail command See how that works for now. Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711610 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 if (isset($_REQUEST['email'])) {//if "email" is filled out, proceed //check if the email address is invalid $mailcheck = spamcheck($_REQUEST['email']); print_r($_REQUEST); die(); Replace that portion of the code with that and report back what is printed to the screen. EDIT: ALso noticed the mail function is wrong. mail($recipient, $subject, $mail_body, $reply, $headers); //mail command SHOULD BE mail($recipient, $subject, $mail_body . $reply, $headers); //mail command Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711613 Share on other sites More sharing options...
codieB Posted December 10, 2008 Author Share Posted December 10, 2008 Premiso, Same as usual. THe form goes through without an error message. I get the email subject line, the body content and the BCC. The only thing I don't get are the NAMES (fname, lname) that should appear at the beginning of the email. Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711617 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 I want to see what this code produces if (isset($_REQUEST['email'])) {//if "email" is filled out, proceed //check if the email address is invalid $mailcheck = spamcheck($_REQUEST['email']); print_r($_REQUEST); // note added this die(); // note added this. To make sure the $_REQUEST array has the values it needs to have. Run that and then paste the array that is returned. Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711620 Share on other sites More sharing options...
codieB Posted December 10, 2008 Author Share Posted December 10, 2008 OK. Let's see if I am following directions correctly. I copy/pasted the code you provided and tested the form in Firefox and Safari. It seemed like business as usual with no error messages. Array returned? None, I think. Does this comply with your statement: "Run that and then paste the array that is returned." Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711626 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 Adding that code should return an Array( setup, not "business as usual" <?php $menu1 = "none"; $menu2 = "none"; $menu3 = "none"; ?> <?php include '../../inc/pageheadhome.inc'; ?> <body id="home" class="colSM"> <?php include '../../inc/header_home.inc'; ?> <? // This is correctly indented ?> <div id="colmain3"> <div class="col3"> <div><div> <dl> <table id="Table_01" background="FACES_register/facesVideo.jpg" width="772" height="585" border="0" cellpadding="0" cellspacing="0"> <tr valign="middle"> <td width="194" valign=""> </td> <td width="561"><table><tr><td colspan="3"><table width="543"> <tr><td width="528" height="188px"> </td> </tr> <tr><td> <?php function spamcheck($field) { //filter_var() sanitizes the e-mail //address using FILTER_SANITIZE_EMAIL $field=filter_var($field, FILTER_SANITIZE_EMAIL); //filter_var() validates the e-mail //address using FILTER_VALIDATE_EMAIL if(filter_var($field, FILTER_VALIDATE_EMAIL)) { return TRUE; } else { return FALSE; } } if (isset($_REQUEST['email'])) { print_r($_REQUEST); // note added this die(); // note added this. //if "email" is filled out, proceed //check if the email address is invalid $mailcheck = spamcheck($_REQUEST['email']); if ($mailcheck==FALSE) { echo "Invalid input"; } else {//send email $Name = "name"; //senders name $email = "from.mycompany.com"; //senders e-mail adress $recipient = $_REQUEST['email']; //recipient $reply = "Congratulations! Video access for " .$_POST['fname']." ".$_POST['lname'].""; $mail_body = "body content"; //mail body //mail body $subject = "Video Access"; //subject $headers = "From: ". $Name . " <" . $email . ">\r\nbcc: blind@company.com\r\n"; //optional headerfields $headers .= "BCC: blindm@company.com\r\n"; mail($recipient, $subject, $mail_body . $reply, $headers); //mail command echo "<font size='3'><font color='#c61317'><strong>Thank you.</font></strong> Please check your email for the access link.</font>"; } } else {//if "email" is not filled out, display the form echo "<form method='post' action='videoAccess.php'> To gain access to the video archive, please fill out the form below.<br /><br /> First Name: <input name='fname' type='text' /><br /> Last Name: <input name='lname' type='text' /><br /> Email: <input name='email' type='text' /><br /><br /> Subject: <strong>Access to FACES archive</strong><br /><br /> <input type='submit' /> </form>"; } ?> Use that code and see what it returns, it should not do any processing, but display a white page with an array element printed out to the screen. Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711636 Share on other sites More sharing options...
codieB Posted December 10, 2008 Author Share Posted December 10, 2008 I'm sorry. I'm just not getting a white screen. When you say RUN the page, you mean test it in a browser, right? I get the form with input fields. Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711648 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 I'm sorry. I'm just not getting a white screen. When you say RUN the page, you mean test it in a browser, right? I get the form with input fields. Yes, fill in the inputs and submit the form. When it hits the section I put in there it will die and print out an array to the screen. Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711665 Share on other sites More sharing options...
codieB Posted December 10, 2008 Author Share Posted December 10, 2008 Hi, It's not working exactly as you suggested. The script doesn't die. When I push SUBMIT, the recipient gets the email. Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711693 Share on other sites More sharing options...
codieB Posted December 10, 2008 Author Share Posted December 10, 2008 Premiso, I take that back. I tried again and got the following: Array ( [fname] => this is this [lname] => gggggg => recipient@gmail.com [__utmz] => 94867584.1228847399.44.11.utmcsr=localhost|utmccn=(referral)|utmcmd=referral|utmcct=/index.php [__utma] => 94867584.2301122497633946400.1225294313.1228861685.1228938133.48 [__utmc] => 94867584 [__utmb] => 94867584.6.10.1228938133 ) Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711722 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 Are you even uploading the new version of the script? It seems like you are not uploading any corrected version and it is staying as the old version, hence why none of the solutions worked. Try this version, since you got the array message now and you know the fields are populated: <?php $menu1 = "none"; $menu2 = "none"; $menu3 = "none"; ?> <?php include '../../inc/pageheadhome.inc'; ?> <body id="home" class="colSM"> <?php include '../../inc/header_home.inc'; ?> <? // This is correctly indented ?> <div id="colmain3"> <div class="col3"> <div><div> <dl> <table id="Table_01" background="FACES_register/facesVideo.jpg" width="772" height="585" border="0" cellpadding="0" cellspacing="0"> <tr valign="middle"> <td width="194" valign=""> </td> <td width="561"><table><tr><td colspan="3"><table width="543"> <tr><td width="528" height="188px"> </td> </tr> <tr><td> <?php function spamcheck($field) { //filter_var() sanitizes the e-mail //address using FILTER_SANITIZE_EMAIL $field=filter_var($field, FILTER_SANITIZE_EMAIL); //filter_var() validates the e-mail //address using FILTER_VALIDATE_EMAIL if(filter_var($field, FILTER_VALIDATE_EMAIL)) { return TRUE; } else { return FALSE; } } if (isset($_REQUEST['email'])) { //if "email" is filled out, proceed //check if the email address is invalid $mailcheck = spamcheck($_REQUEST['email']); if ($mailcheck==FALSE) { echo "Invalid input"; } else {//send email $Name = "name"; //senders name $email = "from.mycompany.com"; //senders e-mail adress $recipient = $_REQUEST['email']; //recipient $reply = "Congratulations! Video access for " .$_POST['fname']." ".$_POST['lname'].""; $mail_body = $reply . "body content"; //mail body //mail body $subject = "Video Access"; //subject $headers = "From: ". $Name . " <" . $email . ">\r\nbcc: blind@company.com\r\n"; //optional headerfields $headers .= "BCC: blindm@company.com\r\n"; mail($recipient, $subject, $mail_body, $headers); //mail command echo "<font size='3'><font color='#c61317'><strong>Thank you.</font></strong> Please check your email for the access link.</font>"; } } else {//if "email" is not filled out, display the form echo "<form method='post' action='videoAccess.php'> To gain access to the video archive, please fill out the form below.<br /><br /> First Name: <input name='fname' type='text' /><br /> Last Name: <input name='lname' type='text' /><br /> Email: <input name='email' type='text' /><br /><br /> Subject: <strong>Access to FACES archive</strong><br /><br /> <input type='submit' /> </form>"; } ?> And make sure that the correct version gets uploaded. That should work. Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711729 Share on other sites More sharing options...
codieB Posted December 10, 2008 Author Share Posted December 10, 2008 Yes. I had been uploading the file to the server, but I copy/pasted your code and tried again---------------same results. I'm starting to suspect that it is a server thing and not the code. We use BlueHost. When I send the file locally, everything goes right. 1. The recipient receives the email 2. The person's name is included in the "Congratulations" message 3. The body comes in just fine 3. I get a BCC The only thing is, instead of the email appearing in my inbox with the name of the sender (included in script) the inbox indicates World Wide Web Server. What do you make of this? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/136378-can-anyone-help-me-get-this-working/#findComment-711755 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.