Hello all!

I've been out of the HTML/PHP scene for a couple years now and I'm feeling a bit dated. Spent the last four years learning Labview and lost my basic web programming skills, it seems.

I'm trying to create a basic survey form for my company's website. I'm working with an example that you have on this site and from a form standpoint, it's nice and easy to modify the look to do what I need it to.

Here is the example: http://www.phpbuilder.com/columns/patterson20051018.php3

I modified the form and uploaded it to a freebie web space to test, and can't seem to get it to work: http://rbrooks8.myhosting247.com/ntd2.html

I thought I modified process.php correctly, but it just doesn't seem to do anything.

Here is my php code (modified from the example code):

<?php

$rate = Array(1=>'10%',
		2=>'20%',
		3=>'30%',
		4=>'40%',
		5=>'50%');
		6=>'60%',
		7=>'70%',
		8=>'80%',
		9=>'90%',
		10=>'100%');

// Get all $_POST variables
foreach($_POST as $var => $val)
{
	${$var} = $val;
}

// Set up the email body
$body_body .=  "Respondent Demographics:\n";
$body_body .=  "    Company-------------| ".$company."\n";
$body_body .=  "    Name----------------| ".$name."\n";
$body_body .=  "    Email Address-------| ".$email."\n";
$body_body .=  "    Phone---------------| ".$phone."\n";
$body_body .=  "----------------------------------------------------\n";
$body_body .=  "Survey Results:\n";
$body_body .=  "    Overall Satisfaction-| ".$rate[$overall]."\n";
$body_body .=  "    Speed of Service-----| ".$rate[$speed]."\n";
$body_body .=  "    Tech Support---------| ".$rate[$rep]."\n";
$body_body .=  "    Product Quality------| ".$rate[$rec]."\n";
$body_body .=  "    Service Value--------| ".$rate[$value]."\n";
$body_body .=  "    Courtesy of Rep------| ".$rate[$courtesy]."\n";
$body_body .=  "    Availability of Rep--| ".$rate[$avail]."\n";
$body_body .=  "    Compared to others---| ".$rate[$comp]."\n";
$body_body .=  "    Comments-------------| ".$feedback."\n";
$body_body .=  "----------------------------------------------------\n";
$body_footer = "Survey Results provided as is from www.nesbearings.com";

$to = 'Ralph Brooks <rbrooks@nesbearings.com>';
$subject = 'Customer Survey Results';
$body = $body_body.$body_footer;

mail($to, $subject, $body);


echo '<div style="white-space: pre">';
print_r(str_replace("\n", "<br />",$body));
echo '</div>';

?>

...

God I hope that posts right and doesn't crash something.

Anyway, I can't get it to email me on that free webspace (it just goes to a blank page), and on another free web space I get a 405 error indicating bad programming.

🙁

Can someone please glance at that and tell me what sucks? I'll be forever grateful.

    I don't know if it's a fatal problem but there's a problem with one of your form field tags

    <td colspan="10"><input type="text" size="40" name="company"</td>

    should be

    <td colspan="10"><input type="text" size="40" name="company" /></td>

      Hey, thanks for that one.

      Is there some chance that both of my hosts just simply don't allow php?

      Also, I know at the bottom where there's options either to send an email or have it display the data, I've remarked them both out and in a couple of times and haven't had any change.

        Does the PHP look ok? Anything there that would be causing errors?

          Huh. That's weird, since I just modified Patterson's example. I'll add that stuff and see what's up then.

          Shouldn't it have at least sent a completely blank email?

            I modified all the 'name' fields with [] and still no dice.

              rbrooks wrote:

              Huh. That's weird, since I just modified Patterson's example. I'll add that stuff and see what's up then.
              Shouldn't it have at least sent a completely blank email?

              Creating an Online Survey - Part 1
              Brett Patterson

              The article and its code is a bit 'older'.

              But this does not have to mean it can not work. Today.

              And can be modified and used if we wish.

              mail servers can be more or less forgiving.
              Some, we can call them KINKY, requires at least a minimum of Headers, to send your mail.
              Reply-To etc
              Others will let go ..

              Study the [man]mail/man function manual.
              Especially those example and Posted Comments
              that use some HEADERS.

              I always use with 4 arguments (from which one is HEADERS)

              // first 
              // prepare 4 arguments, variables for mailing
              
              //send it
              $success = mail( $a1, $a2, $a3, $a4 );
              
              //see if was any problem, error
              if($success)
                  exit('your message was sent ....... we think');
              else
                  exit('there was some problem to send your message 
                              ....... please come back later, Thanks');

              regars 🙂
              halojoy

                I'm looking around on the php mail manual and seeing lots of code that is beyond my grasp.

                So you're saying that one of the arguments other than to, subject, body should be header data?

                Since I'm completely clueless as to how to fetch header data and/or generate it, this has me at another impasse.

                I still am thinking that my server simply doesn't have sendmail or something similar available to me.

                Is there any way to test this code on my desktop to see if it's even TRYING to do what I want it to?

                Eventually this will end up on a real server with sendmail, etc, but I'm unable to upload it to that server at this time. I need to have the code finished and working before doing that, since my company has an archaic agreement with a local hosting place that costs upwards of $50 a month for basic hosting and anytime something needs changed, uploaded, or troubleshooted the charge goes up. They still charge per 5mb email account. It's a mess, and my company owner is 'friends' with this guy that's raping him so he won't change.

                Either way I need to have working code before I approach him so it doesn't cost an arm and a leg to get it implemented.

                  I would just get an account with a shared hosting company such as servage, the price is as little as $6.50 a month, i use them and there is very little downtime

                    Believe me, that's the direction I'm trying to steer him. In the meantime, unless I want to buy some web space out of my own pocket, I can't test this code on something that I know has access to sendmail.

                    I'm fairly certain that my freebie account on myhosting247 does NOT have sendmail, which would definitely prevent me from receiving the email.

                    But that part at the bottom which should display the data on the screen, that also doesn't work. I don't understand why that would be affected by the missing sendmail.

                      After a bit of a battle with the hosting guy, I got access to the cpanel for the site.

                      After uploading my code, it works. I'm a little unhappy with the formatting of the email, in that the 'from' or 'sender' just comes up 'Nobody'.

                      Is there any way to add an argument that will take the 'name' or 'email' attribute from the preceding form and add it as the sender in the mail I recieve? I tried doing a $sender = $name and adding the $sender to the next two lines, but it got buggy on me. I got it to show up in the subject, but not the 'from'.

                      Ideas?

                        Also, if I can somehow use the 'email' variable in the 'to' field, it would be nice for the sender to get a copy of the form they'd just filled out.

                          Write a Reply...