5 Replies Latest reply on Apr 14, 2010 12:54 PM by dan hop

    PHP and JavaScript help please...

    dan hop Level 1

      Can you please help me figure out why this doesn't work?

       

      Dan H.

      Version:1.0 StartHTML:0000000105 EndHTML:0000004276 StartFragment:0000002313 EndFragment:0000004240

      <HEAD>

      <SCRIPT type="text/javascript">

      /*This script is supposed to combine the first and last names and send them to the PHP script as one variable $name*/

      fName=inputform.P_FNAME()

      lName=inputform.P_LNAME()

      cName=fName.' '.lName

      </SCRIPT>

      </HEAD>

       

      <BODY>

      <INPUT name="P_FNAME" type="text" class="formtext" size="20" maxlength="20">

      <INPUT name="P_LNAME" type="text" class="formtext" size="25" maxlength="25">

       

      <INPUT name="cName" type="text" class="hiddenClass" value=cName>

      </BODY>

       

      The PHP script has a field:

                  $reply_to_name[3]="name";

       

      that it uses in the ‘from’ part of the email address

       

      So if fName is ‘BOB’ (P_FNAME)

      and lName is ‘Jones’ (P_LNAME)

      the resulting email should be from:

                  Bob Jones@someplace.com

        • 1. Re: PHP and JavaScript help please...
          Ben M Adobe Community Professional

          This might sound crazy, but if you have two form variables being passed in a php script when the form is submitted, why don't you join the variables in the PHP script?  ie: $name = $_POST['fname'].$_POST['lname'];

          • 2. Re: PHP and JavaScript help please...
            dan hop Level 1

            Thank you for your suggestion.

             

            I tried it:

             

                $reply_to_field[3]="P_EMAIL";
                $reply_to_name = $_POST['P_FNAME'].' '.$_POST['P_LNAME'];

            [I tried it with the .' '. in the middle to separate the first and last names

               and I tried it without the ' '. - no luck...]

             

            Didn't work...

            All I got was the email address (no name).

             

            NOTE-both 'P_FNAME' and 'P_LNAME' display in the body of the resulting email as expected,

            but not in the head (from Joe Blow-joeblow21@someplace.com-

            [I used '-' above instead of the greater than/less than signs so it would display here.]

             

            Dan H.

            • 3. Re: PHP and JavaScript help please...
              BCDoherty Level 3

              It might help to straighten out the php/javascript confusion. php will not execute within script tags.

              • 4. Re: PHP and JavaScript help please...
                Ben M Adobe Community Professional

                The code should have been written the way I had it:

                 

                $name = $_POST['fname'].$_POST['lname'];

                 

                To clarify this, the $_POST designates the method, so if your form method is get, you have to replace it with $_GET and the ['fname'] is ['var'] so the name has to match the name of the field.

                 

                If you post more of your code I could try to help you get the issue resolved but with the bit you posted I don't really have much more to suggest.

                1 person found this helpful
                • 5. Re: PHP and JavaScript help please...
                  dan hop Level 1

                  Based on SnakEyez02's suggestion, I abandoned (at least for now) the JavaScript part of the project.

                  (Thank you SnakEyez02 for offering to help...)

                   

                  This is in a form called form3.php:

                   

                  The form[3] now contains the following INPUT fields:

                   

                       <INPUT name="P_FNAME" type="text" class="formtext" size="20" maxlength="20">

                       <INPUT name="P_LNAME" type="text" class="formtext" size="25" maxlength="25">

                       <INPUT name="P_EMAIL" type="text" class="formtext" size="50" maxlength="240">

                   

                  The formmail.php script contains the following required variables:

                   

                       $reply_to_field[3]="P_EMAIL";
                       $reply_to_name[3] = $_POST['P_FNAME'].$_POST['P_LNAME'];/*Doesn't work*/

                   

                  I believe that's faithful to your recommendation...

                  The resulting email contains the correct email address of the submitter, but NOT the name...

                  I also tried replacing the single quotes ' with double quotes " - same result.

                   

                  What I've read on the net, etc., suggest to me that it should work!

                  Can't figure out why it doesn't...

                   

                  Ideally, they first name and the last name would be separated by a space [.' '.]

                   

                  I'm using DBmasters-FormMailer:

                  http://www.dbmasters.net/node/18

                   

                  Dan H.