question about Values submitted from web site form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Lflagg
    Sergeant First Class

    • Aug 2007
    • 51

    question about Values submitted from web site form

    hello,
    i have a quick question. im trying to make a simple form, with names, phones, emails, some check boxes (yes or No), etc. where im getting confused is in the code that i have to insert in my "thank you" page. in this part (in blue): $mailbody = "Values submitted from web site form :\n"; do i have to leave the:\n; ? (it was not highlited in blue in the tutorial).
    how do i put the values? divided by commas? between ""? i really dont understand this part. can somoene give me an example so i can use it as a base but use my values?
    thanks.
  • Andy128
    Major General

    • Dec 2005
    • 2317

    #2
    Re: question about Values submitted from web site form

    Yes- leaave the \n

    Only change what is in blue to suit your needs.
    For example:
    $mailbody ="Input from website form- MySite.com:\n";

    Andy
    PHP- is a blast!

    Comment

    • Lflagg
      Sergeant First Class

      • Aug 2007
      • 51

      #3
      Re: question about Values submitted from web site form

      thanks Andy! i figured it out....
      another question: i have some checkboxes in the form. but when i receive the email (im doing tests still to myself), the values are empty. it doesnt appear if they were checked or not. how do i do this?
      thanks again!

      Comment

      • Andy128
        Major General

        • Dec 2005
        • 2317

        #4
        Re: question about Values submitted from web site form

        Check boxes- if you allow multiple selections, requires a little additional scripting. Could you post the php script that you are currently using and also post the link to the form. I will have a look and see what we can do.

        Andy
        PHP- is a blast!

        Comment

        • Lflagg
          Sergeant First Class

          • Aug 2007
          • 51

          #5
          Re: question about Values submitted from web site form

          this si the script:
          <?PHP
          $mailto = "seniorhelpers******.com";
          $email = $HTTP_POST_VARS['email'];
          if ($email == "") {
          $email = $mailto;
          }
          $mailsubj = "Caregiver Employment Submission Form";
          $mailhead = "From: $email\n";
          reset ($HTTP_POST_VARS);
          $mailbody = "first, Last, phone_number, second_number, city, state, zip,how_hear_about_us, years_experience,cna,hha,companion,hours_available ,full_time, part_time,day_shift,Night_shift, weekends,live_in,flexible,have_car,email,drives,co mments:\n";
          while (list ($key, $val) = each ($HTTP_POST_VARS))
          {
          if ($key!="submit")
          {
          $mailbody .= "$key : $val\n";
          }
          }
          mail($mailto, $mailsubj, $mailbody, $mailhead);
          ?>

          the checkboxes are for these values:
          CNA, HHA, Companion, Full time, part time, wekkends, live-in, flexible, Day Shift and night shift.

          thanks.

          Comment

          • Lflagg
            Sergeant First Class

            • Aug 2007
            • 51

            #6
            Re: question about Values submitted from web site form

            the link to the form:

            Comment

            • Andy128
              Major General

              • Dec 2005
              • 2317

              #7
              Re: question about Values submitted from web site form

              The reason that they are not showing up is there is no value assigned to it. So in the value portion of those check boxes in question- simply give it a value of "Yes". That way, if it is checked- you will receive a "Yes".

              However. You will receive an e-mail with a bunch of yes's and not know where they are supposed to go with. Give it a try and see how it looks in
              your e-mail.

              If you would like a nice clean format received in your mail do the following:
              1- in your form, make sure that all fields that have two or three parts to their name are joined by an underscore. Example: first_name, last_name were done correctly. Do the same for part_time, full_time, day_shift, night_shift, second_phone_number, Hear_from_us, Years_experience, Live_in etc......

              2- You have the comments box named Comments? Remove the ? -So it should be Comments

              3- Remove the php code that you are using and replace it with this one below: (**Make a copy first incase you don't like my style)

              **Stand BY- still writing code
              PHP- is a blast!

              Comment

              • Andy128
                Major General

                • Dec 2005
                • 2317

                #8
                Re: question about Values submitted from web site form

                Last part of step 3- **Sorry, had to modify what I had originally posted.

                <?PHP
                $date = date("l jS F Y, g:i A");
                $ip = $_SERVER['REMOTE_ADDR'];
                $first_name =$_POST['first_name'];
                $last_name =$_POST['last_name'];
                $phone_number =$_POST['phone_number'];
                $second_phone_number =$_POST['second_phone_number'];
                $city =$_POST['city'];
                $State =$_POST['State'];
                $Hear_from_us =$_POST['Hear_from_us'];
                $Years_experience =$_POST['Years_experience'];
                $cna =$_POST['cna'];
                $hha =$_POST['hha'];
                $companion =$_POST['companion'];
                $Full_time =$_POST['Full_time'];
                $part_time =$_POST['part_time'];
                $day_shift =$_POST['day_shift'];
                $night_shift =$_POST['night_shift'];
                $weekends =$_POST['weekends'];
                $flexible =$_POST['flexible'];
                $Live_in =$_POST['Live_in'];
                $havecar =$_POST['havecar'];
                $doyoudrive =$_POST['doyoudrive'];
                $Comments =$_POST['Comments'];
                //////////////////////////////////////////////////////
                $mailto = "seniorhelpers******.com";
                $email = $HTTP_POST_VARS['email'];
                if ($email == "")
                {
                $email = $mailto;
                }
                $mailsubj = "Caregiver Employment Submission Form";
                $mailhead = "From: $email\n";
                reset ($HTTP_POST_VARS);
                $mailbody = "Form Data from Senior Helpers website:\n"
                . "-------------------------------------------------------------\n"
                . "Received on : $date\n"
                . "IP address : $ip\n"
                . "-------------------------------------------------------------\n"
                . "First Name: $first_name\n"
                . "Last Name : $last_name\n"
                . "Phone Number: $phone_number\n"
                . "Second Phone: $second_phone_number\n"
                . "City: $city\n"
                . "State: $State\n"
                . "-------------------------------------------------------------\n"
                . "Hear about us from: $Hear_from_us\n"
                . "-------------------------------------------------------------\n"
                . "Years of Experience: $Years_experience\n"
                . "-------------------------------------------------------------\n"
                . "Type of Care Giver-CNA: $cna\n"
                . "Type of Care Giver-HHA: $hha\n"
                . "Type of Care Giver-Companion: $companion\n"
                . "--------------------------------------------------------------\n"
                . "Avaliable to work Full Time: $Full_time\n"
                . "Avaliable to work Part Time: $part_time\n"
                . "Avaliable to work Day Shift: $day_shift\n"
                . "Avaliable to work Night Shift: $night_shift\n"
                . "Avaliable to work Weekends: $weekends\n"
                . "Avaliable to work Flexible: $flexible\n"
                . "Avaliable to work Live In: $Live_in\n"
                . "--------------------------------------------------------------\n"
                . "Do you have a car: $havecar\n"
                . "Do you Drive: $doyoudrive\n"
                . "--------------------------------------------------------------\n"
                . "Email address: $email\n"
                . "--------------------------------------------------------------\n"
                . "Comments: $Comments\r\n";
                mail($mailto,$mailsubj,$mailbody,$mailhead);
                ?>

                Give this a try and see if you like its output a little better.

                Andy
                PHP- is a blast!

                Comment

                • Lflagg
                  Sergeant First Class

                  • Aug 2007
                  • 51

                  #9
                  Re: question about Values submitted from web site form

                  wow. thank you so much!!! i will try this code and i will let u know how it worked!
                  im curious though.... what will this change do?
                  thanks.

                  Comment

                  • Andy128
                    Major General

                    • Dec 2005
                    • 2317

                    #10
                    Re: question about Values submitted from web site form

                    It will simply put it in a more readable and organized output. Like I said- try both- print them out and see which you like better. Remember to copy your first one in note pad just in case mine doesn't work or there are problems.

                    In any event- if you have problems or questions just post abck.

                    Andy
                    PHP- is a blast!

                    Comment

                    • Lflagg
                      Sergeant First Class

                      • Aug 2007
                      • 51

                      #11
                      Re: question about Values submitted from web site form

                      hello, i tried it and the email didnt come trhough...so i couldnt really check how it looks....

                      also, i remember u mentioned about having the option to check several checkboxes, that i need another script? have no idea how to do that.
                      thanks again!

                      Comment

                      • Watdaflip
                        Major General

                        • Sep 2005
                        • 2116

                        #12
                        Re: question about Values submitted from web site form

                        Alternatively you can just name all of the check boxes the same and add [] at the end.

                        For instance set the "name" of each checkbox to "hours_available[]"

                        And then in the script do something like
                        Code:
                        <?PHP
                        $mailto = "seniorhelpers******.com";
                        [COLOR=Red]$hours_available = $HTTP_POST_VARS['[/COLOR][COLOR=Red]hours_available[/COLOR][COLOR=Red]'];[/COLOR]
                        $email = $HTTP_POST_VARS['email'];
                        if ($email == "") {
                        $email = $mailto;
                        }
                        $mailsubj = "Caregiver Employment Submission Form";
                        $mailhead = "From: $email\n";
                        reset ($HTTP_POST_VARS);
                        $mailbody = "first, Last, phone_number, second_number, city, state, zip,how_hear_about_us, years_experience,cna,hha,companion,hours_available ,full_time, part_time,day_shift,Night_shift, weekends,live_in,flexible,have_car,email,drives,co mments:\n";
                        while (list ($key, $val) = each ($HTTP_POST_VARS))
                        {
                        if ($key!="submit")
                        {
                        $mailbody .= "$key : $val\n";
                        }
                        }
                        
                        [COLOR=Red]$mailbody .= "Hours Available \n";
                        for($i=0; $i < count($[/COLOR][COLOR=Red]hours_available[/COLOR][COLOR=Red]); $i++)
                        {
                        $mailbody .= $[/COLOR][COLOR=Red]hours_available[/COLOR][COLOR=Red][$i]."\n";
                        }[/COLOR]
                        mail($mailto, $mailsubj, $mailbody, $mailhead);
                        ?>
                        And then just set the values for each checkbox to the label you want to display in the email.. so set the values of each checkbox to "Full Time", "Part Time", "Day Shift", etc.


                        The only disadvantage to doing it this way is that since the rest of the email is being generated and the format isn't hard coded in, doing is this way all the check boxes have to go before or after the the rest of the email body.

                        Andy's way hard codes the email message, so its in the same order as the form.

                        Register/Login Script
                        Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

                        Comment

                        • Lflagg
                          Sergeant First Class

                          • Aug 2007
                          • 51

                          #13
                          Re: question about Values submitted from web site form

                          oh... u lost me completely....
                          i have no idea about php or codes...i tried to read the code and figure what to do, but i couldnt....

                          may i ask you another question? i need 2 different action pages. i have a form for applicants and one for clients that want more info about our services. the "thank you" (action) page for the applicants was working well until i pasted the code that i was given (i don't receive the email even though the email is right). so i dont knwo what to do there....
                          and then, when the clients fill up the other form, i need them to end up in another "thank you" action page. should i call it action1.php? how do i do this?
                          thanks so much!

                          Comment

                          • Watdaflip
                            Major General

                            • Sep 2005
                            • 2116

                            #14
                            Re: question about Values submitted from web site form

                            Theres any number of ways to do it. You can create multiple action pages (you don't even have to call it "action", you can call it client_contact.php, or what not). You can setup multiple forms that each goes to a different .php file to send the email, or have all the forms go to the same one, and write some code to have the php script distinguish which email to use based on which form submitted it.

                            Register/Login Script
                            Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

                            Comment

                            • Lflagg
                              Sergeant First Class

                              • Aug 2007
                              • 51

                              #15
                              Re: question about Values submitted from web site form

                              oh i see! is not the name but the extension PHP.
                              gotcha! thanks so much.
                              now.... regarding the checkboxes... still didnt get that part....

                              Comment

                              Working...
                              X