Web Analytics Made Easy -
StatCounter PHP scripting problem - CodingForum

Announcement

Collapse
No announcement yet.

PHP scripting problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP scripting problem

    Hi all,

    I am new on here and having trouble with a PHP script which I have written for processing a web form and converting it to email.

    This is the php script (sendmail.php)

    <?
    $email = $_REQUEST['email'] ;
    $yourmessage = $_REQUEST['yourmessage'] ;
    $name = $_REQUEST['name'] ;
    $address = $_REQUEST['address'] ;
    $postcode = $_REQUEST['postcode'] ;
    $phoneno = $_REQUEST['phoneno'] ;
    $preferred_means_of_contact = $_REQUEST['preferred_means_of_contact'] ;

    mail( "[email protected]", "Feedback Form Results",
    $yourmessage, "From: $email", "$embody = $name $address $postcode $phoneno $preferred_means_of_contact");
    header( "Location: http://www.mydomain.co.uk/contact_thanks.html" );
    ?>
    The problem is that when I submit the form on my browser, nothing happens and eventually, the browser brings up a dialog box asking if I want to download sendmail.php rather than processing the form. If I only use the $email and $yourmessage parameters then the script works fine........

    I would be very grateful for any assistance, I have trawled the net for a solution but cannot find any.

    Many thanks

    RMD

  • #2
    I don't think that's how the 'additional paramaters' part of the mail() function works, are you guessing or do you know for sure that it does?
    (if you are sure that's what you're meant to pass, where is $embody coming from?)
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

    Comment


    • #3
      I found the $embody from some other forum that came up on google.....

      Comment


      • #4
        I have modified the script and removed '$embody'. So the script no looks like this:

        Code:
        <?
          $email = $_REQUEST['email'] ;
          $yourmessage = $_REQUEST['yourmessage'] ;
          $name = $_REQUEST['name'] ;
          $address = $_REQUEST['address'] ;
          $postcode = $_REQUEST['postcode'] ;
          $phoneno = $_REQUEST['phoneno'] ;
          $preferred_means_of_contact = $_REQUEST['preferred_means_of_contact'] ;
        
          mail( "[email protected]", "Feedback Form Results",
            "$yourmessage", "From: $email", "$name", "$address", "$postcode", "$phoneno", "$preferred_means_of_contact");
          header( "Location: http://www.mydomain.co.uk/contact_thanks.html" );
        ?>
        When I submit the form, the browser displays the following error message:

        Warning: mail() expects at most 5 parameters, 9 given in /home/fhlinux181/b/mydomain.co.uk/user/htdocs/sendmail.php on line 11

        Warning: Cannot modify header information - headers already sent by (output started at /home/fhlinux181/b/mydomain.co.uk/user/htdocs/sendmail.php:11) in /home/fhlinux181/b/mydomain.co.uk/user/htdocs/sendmail.php on line 12
        Any further help greatly appreciated.

        Comment


        • #5
          The error message is about as explanatory as you can get, you're sending too many arguments.
          As I understand it, and if someone who thinks they know what they're talking about comes along and says otherwise I'll happily give way, the 'additional paramaters' paramater to mail (i.e. the 5th one) is for additional paramaters to the actual mail-sending process.
          Passing it postcodes and phone-numbers isn't going to make it happy.
          mail($to,$subject,$message,$headers);
          is all I've ever needed, so why are you putting those extra variables elsewhere?
          My thoughts on some things: http://codemeetsmusic.com
          And my scrapbook of cool things: http://gjones.tumblr.com

          Comment


          • #6
            More descriptive subject

            In the future, please use a more descriptive subject when posting a question. See posting guidelines. We already know that you have a PHP scripting problem otherwise you wouldn't be posting here.
            Spookster
            CodingForum Supreme Overlord
            All Hail Spookster

            Comment


            • #7
              Is there anywhere else I can put the variables - I need as much contact details as possible.

              Comment


              • #8
                right, I think I understand what you're trying to do now...

                You can append those extra bits of information to the message, something like:
                PHP Code:
                [...] //the same code at the top, but then:
                $actual_message=$yourmessage."\n--------------------\n".$name."\n".$address //etc.

                mail"[email protected]""Feedback Form Results"$actual_message"From: $email"
                My thoughts on some things: http://codemeetsmusic.com
                And my scrapbook of cool things: http://gjones.tumblr.com

                Comment


                • #9
                  GJay, you're a star

                  Many, Many thanks

                  Comment

                  Working...
                  X