Webmaster Forum

Sponsored Reviews   High Bandwidth Dedicated Servers   V7N Directory
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Reply
 
LinkBack Thread Tools Display Modes
Old 10-17-2007, 12:23 PM   #1 (permalink)
v7n Mentor
 
watley's Avatar
 
Join Date: 07-26-06
Location: Illinois
Posts: 1,439
iTrader: 0 / 0%
Latest Blog:
None

watley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest order
Question Why won't my php form email results?

I'm trying to set up a survey using a php script that is supposed to mail the results to me. The script appears to work fine except that it doesn't seem to be mailing anything. Nothing, nada, zip.

I'll be honest: I'm not a php expert and this isn't my schtick. I'm borrowing a script (actually I've tried several) that I found online. But I'm not a complete dummy, I tweak and use free scripts all the time, and I think I've modified these scripts appropriately. Could there be some server setting that is causing trouble? It's an OSX server running php5.

Any insight would be appreciated!
__________________
---> This space intentionally left blank. <---
watley is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 10-17-2007, 12:26 PM   #2 (permalink)
Contributing Member
 
Skinny's Avatar
 
Join Date: 02-08-07
Posts: 542
iTrader: 2 / 100%
Latest Blog:
Erguvan Platin

Skinny is just really niceSkinny is just really niceSkinny is just really niceSkinny is just really niceSkinny is just really niceSkinny is just really niceSkinny is just really niceSkinny is just really niceSkinny is just really niceSkinny is just really niceSkinny is just really nice
Would it be possible to post the script here or at least have access to it.

It would make it easier to look at.

Also do you get any kind of error message when you complete the script.

Skinny
__________________
Blandless Web Gallery - Bland is Dead! See the Best Designed Websites.

Need a High Quality Logo? I can help you!
Skinny is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-17-2007, 01:10 PM   #3 (permalink)
v7n Mentor
 
watley's Avatar
 
Join Date: 07-26-06
Location: Illinois
Posts: 1,439
iTrader: 0 / 0%
Latest Blog:
None

watley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest order
There is no error message... it correctly displays the "thank you" page when the user clicks the "submit" button.

This is the code; I've taken out most of the questions for brevity's sake.

Code:
<?php # ------------------------------------------------------------------- # License and copyright: # # This program is designed and copyrighted by # Aaron Colman on August 5, 2004 under the terms # of the GPL provided under gpl.txt # # For more information visit http://www.ibasics.biz # or write me at aaron@ibasics.biz # # I will be updating this software as time goes # on, if you want the newest version... that's # where you need to go. # # No warranty of any kind is implied or expressed. # Neither fitness for a purpose nor warranty of # merchantability. You alone are liable for your # own actions with this script. If something goes # wrong it's your fault and you get to deal with # the consequences. Not I! If you don't agree with # these terms then don't use this script. # ------------------------------------------------------------------- # Get URL-based and absolute-based directory and filename. $thisfile_URL = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']; $thisdir_URL = substr($thisfile_URL, 0, strrpos($thisfile_URL, '/')).'/'; $thisfile_ABS = $_SERVER['SCRIPT_FILENAME']; $thisdir_ABS = substr($thisfile_ABS, 0, strrpos($thisfile_ABS, '/')).'/'; # ------------------------------------------------------------------- # ***** CONFIGURATION SETTINGS ***** # The Email address you want results mailed to. $email_to_send_to = 'editor@watleyreview.com '; # The name of the survey. What do you want to call it? $name_of_survey = 'Test Survey'; # Template files to load. The opening template, the close template. # The template displayed before the survey form is printed and # The template displayed after the email is sent. Or leave empty. $open_template = $thisdir_ABS."templates/open.php"; $close_template = $thisdir_ABS."templates/close.php"; $survey_heading_page = $thisdir_ABS."templates/head.php"; $survey_complete_page = $thisdir_ABS."templates/done.php"; # The charset being used for all messages sent out. ISO-8859-1 by default, # but you can use anything you want (Unicode, etc). $charset = 'ISO-8859-1'; # ------------------------------------------------------------------- # ----------------------- Survey Form Information ------------------- # Type: checkbox # Deft: Y or N for default check. # # Type: radio # Deft: Default selected option # Opts: Array of option values # # Type: select # Deft: Default selected option # Opts: Array of option values # # Type: text # Deft: Default field text # Opts: maxl, size - Maxlength and field size # # Type: textarea # Deft: Default textarea field text # Opts: rows, cols - row size, column size # # $hidden is an array of hidden fields. # key being the name of the field, value as the value. # # $button_text is the submit button text # ------------------------------------------------------------------- # ***** SAMPLE DATA ***** $question['1']['type'] = 'radio'; $question['1']['desc'] = '1) The newsletter provides sufficient background information for the meetings.'; $question['1']['deft'] = '3'; $question['1']['opts'][] = 'Strongly agree'; $question['1']['opts'][] = 'Agree'; $question['1']['opts'][] = 'Neither agree nor disagree'; $question['1']['opts'][] = 'Disagree'; $question['1']['opts'][] = 'Strongly disagree'; $question['2']['type'] = 'radio'; $question['2']['desc'] = '2) I usually read most or all of the newsletter.'; $question['2']['deft'] = '3'; $question['2']['opts'][] = 'Strongly agree'; $question['2']['opts'][] = 'Agree'; $question['2']['opts'][] = 'Neither agree nor disagree'; $question['2']['opts'][] = 'Disagree'; $question['2']['opts'][] = 'Strongly disagree'; $question['3']['type'] = 'radio'; $question['3']['desc'] = '3) The new design is:'; $question['3']['deft'] = '3'; $question['3']['opts'][] = 'Much better'; $question['3']['opts'][] = 'Somewhat better'; $question['3']['opts'][] = 'About the same'; $question['3']['opts'][] = 'Somewhat worse'; $question['3']['opts'][] = 'Much worse'; $question['4']['type'] = 'radio'; $question['4']['desc'] = '4) The newsletter covers the subjects and stories I think are important.'; $question['4']['deft'] = '3'; $question['4']['opts'][] = 'Strongly agree'; $question['4']['opts'][] = 'Agree'; $question['4']['opts'][] = 'Neither agree nor disagree'; $question['4']['opts'][] = 'Disagree'; $question['4']['opts'][] = 'Strongly disagree'; $question['5']['type'] = 'textarea'; $question['5']['desc'] = 'Additional Comments'; $question['5']['deft'] = 'Default Junk'; $question['5']['opts']['rows'] = '10'; $question['5']['opts']['cols'] = '30'; $button_text = 'Submit your answers'; # ------------------------------------------------------------------- function my_remove_slashes($st) { if (get_magic_quotes_gpc()) { return stripslashes($st); } else { return $st; } } function security_filter($st) { $attribs = 'javascript:|onclick|ondblclick|onmousedown|onmouseup|onmouseover|'. 'onmousemove|onmouseout|onkeypress|onkeydown|onkeyup'; $st = my_remove_slashes($st); $st = stripslashes(preg_replace("/$attribs/i", 'forbidden', $st)); $st = strip_tags($st); $st = htmlentities($st); return $st; } # ------------------------------------------------------------------- if (!(empty($open_template))) { include($open_template); } if (isset($_POST['button'])) { foreach ($_POST as $key => $value) { if ($key != 'button') { if (preg_match('/^hidden_(.*)/i',$key)) { $value = security_filter($value); $key = trim(strstr($key,'_'),'_'); if (isset($hidden[$key])) { $hidden_data[$key] = $value; } } else { if (isset($question[$key])) { $value = security_filter($value); if ($question[$key]['type'] == 'checkbox') { $value = "YES"; } $results[$key] = $value; } } } } # Now that the responses are processed, prepare the email. $msg = "----------------- User Info -----------------\n\n"; $msg .= "Sent from: ".$_SERVER['REMOTE_HOST']." [".$_SERVER['REMOTE_ADDR']."] \n"; $msg .= "Coming from (referer): ".$_SERVER['HTTP_REFERER']."\n"; $msg .= "Using (user agent): ".$_SERVER['HTTP_USER_AGENT']."\n\n"; $msg .= "---------------------------------------------\n\n"; if (isset($question)) { $lineflag = FALSE; foreach ($results as $key => $value) { if ($lineflag == FALSE) { $msg .= "----------------- Questions -----------------\n\n"; $lineflag = TRUE; } $msg .= "Question: ". $key ." - ". $question[$key]['desc'] ."\n"; $msg .= "Response: ". $value . "\n\n"; } $msg .= "---------------------------------------------\n"; } $msg .= "\n"; # Prep and send email. $headers = 'Return-Path: $email_to_send_to\r\n'; $headers .= 'From: Newsletter Survey processor <ccst@ccst.us>\r\n'; $headers .= 'Content-type: text/plain; charset=$charset\r\n'; mail($email_to_send_to, $name_of_survey, $msg, $headers); # Include template file. if (!(empty($survey_complete_page))) { include($survey_complete_page); } } else { if (!(empty($survey_heading_page))) { include($survey_heading_page); } print "<form action=\"$thisfile_URL\" method=\"POST\"> \n"; foreach ($question as $key => $value) { $type = strtolower($question[$key]['type']); $desc = $question[$key]['desc']; $deft = $question[$key]['deft']; $opts = $question[$key]['opts']; print $desc."\n"; if ($type == "checkbox") { if (strtolower($deft) == 'y') { $box_value = "1"; $CHECKED = ' CHECKED'; } else { $box_value = "0"; $CHECKED = ''; } print "<input type=\"checkbox\" name=\"$key\" value=\"$box_value\"$CHECKED>\n<br>"; } if ($type == "radio") { print "<br>\n"; $i = 1; foreach ($opts as $opt_key => $opt_value) { if ($deft == $i) { $CHECKED = " checked=\"checked\""; } else { $CHECKED = ''; } print "<input type=\"RADIO\" name=\"$key\" value=\"$opt_value\"$CHECKED> - $opt_value <br>\n"; $i++; } } if ($type == "select") { print "<br>\n"; print "<select name=\"$key\">\n"; $i = 1; foreach ($opts as $opt_key => $opt_value) { if ($deft == $i) { $CHECKED = ' SELECTED'; } else { $CHECKED = ''; } print "<option value=\"$opt_value\"$CHECKED>$opt_value</option>\n"; $i++; } print "</select><br>\n"; } if ($type == "text") { print "<br>\n"; $size = $opts['size']; $maxl = $opts['maxl']; print "<input maxlength=\"$maxl\" size=\"$size\" name=\"$key\" value=\"$deft\"><br>\n"; } if ($type == "textarea") { print "<br>\n"; $colz = $opts['cols']; $rowz = $opts['rows']; print "<textarea name=\"$key\" rows=\"$rowz\" cols=\"$colz\">$deft</textarea><br>\n"; } # Spacing between survey questions ----------- print "<br>\n"; # -------------------------------------------- mail($email_to_send_to, $name_of_survey, $msg, $headers); } foreach ($hidden as $key => $value) { print "<input type=\"hidden\" name=\"hidden_$key\" value=\"$value\">\n"; } print "<input type=\"submit\" name=\"button\" value=\"$button_text\">\n"; print " &nbsp; -- &nbsp; \n"; print "<INPUT TYPE=\"reset\" VALUE=\"Clear\">\n"; print "</form>"; print "<center><font size=\"2\">Powered by <A HREF=\"http://www.ibasics.biz/sss\">Super Simple Survey</A></font></center><br>\n"; } if (!(empty($close_template))) { include($close_template); } ?>
__________________
---> This space intentionally left blank. <---

Last edited by chicgeek : 10-21-2007 at 01:50 PM.
watley is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-20-2007, 12:16 PM   #4 (permalink)
v7n Mentor
 
Taltos's Avatar
 
Join Date: 11-22-06
Location: Phoenix, AZ
Posts: 1,784
iTrader: 0 / 0%
Latest Blog:
None

Taltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web pro
Send a message via Yahoo to Taltos
Hey watley, did you ever get this solved? I spent a few minutes taking a quick look and nothing stood out as a problem. Doesn't mean there isn't one but... Have you checked the default email address at this site to see if you are getting any bounce messages? There is usually a default email address that is not one you set up that accepts email to the domain that is not properly addressed. It doesn't look like the script is using any kind of "from" address so the default domain email address would probably be the only place bounce messages would appear. If the bounces do exist, they would give you and us more info. First, it would mean you are sending something. Second, you could see if there is some kind of code problem with building the message. As for OSX, I run from macs so I don't know what that might do to the problem. Good luck and let me know.
__________________
Experimenting
Taltos is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-23-2007, 10:17 AM   #5 (permalink)
v7n Mentor
 
watley's Avatar
 
Join Date: 07-26-06
Location: Illinois
Posts: 1,439
iTrader: 0 / 0%
Latest Blog:
None

watley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest orderwatley is a web professional of the highest order
Wasn't solved, Taltos. I'll check the email logs. Thanks for the suggestion. You rock.
__________________
---> This space intentionally left blank. <---
watley is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-26-2007, 07:36 AM   #6 (permalink)
Contributing Member
 
Join Date: 09-03-07
Location: England
Posts: 359
iTrader: 0 / 0%
Latest Blog:
None

Boogle is liked by somebodyBoogle is liked by somebodyBoogle is liked by somebodyBoogle is liked by somebodyBoogle is liked by somebody
That almost is definitely server settings; does it work to send to internal mail add?

Also, that stinks a bit have you seen how easy the c# .NET mailMessage class is? makes that look like super chinese script crossed with dog langauge!

obviously that's just my opinion

Boog's
__________________
Price is what you pay... Value is what you get.

Last edited by Boogle : 10-26-2007 at 07:56 AM.
Boogle is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Email form headaches rearadmiral Coding Forum 2 06-15-2007 06:52 AM
PHP: Email form Optix Coding Forum 20 04-13-2007 05:04 PM
EMAIL FORM Rossco Web Design Lobby 3 10-29-2006 10:07 AM
Insert form results to a hidden field... malhyp Coding Forum 3 06-02-2006 09:10 AM
Submit form results to iframe Spiral Coding Forum 4 08-10-2004 11:42 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 01:17 PM.
© Copyright 2008 V7 Inc


Search Engine Optimization by vBSEO 3.1.0 ©2007, Crawlability, Inc.