Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Web Design (WordPress, Joomla, etc.) javascript question

  • Posted by Bret Williams on May 4, 2005 at 5:39 pm

    In an email form I’m using a php script to send the email. I’d like the subject to be a combination of fields on the form.

    Currently, I can set any of the fields to be called “subject” and then it will be the subject of the email.

    The script provides code to create the default subject to “form submission” if there is no subject field. I thought this might be the easiest place to adjust the javascript if I had a clue what I was doing!

    The line I’d like to adjust is…
    // if the subject option is not set: set the default
    if (!$subject)
    $subject = “Form submission”;

    What I’d like to do is change the text from Form submission to “# of attendees” and then add the result of the attendees field so that the subject line reads… “# attendees 2” (without the quotes of course.

    I know this must be simple. I just don’t know javascript.

    Bret Williams replied 19 years, 9 months ago 2 Members · 5 Replies
  • 5 Replies
  • Bret Williams

    May 4, 2005 at 8:58 pm

    Replace all mentions of Javascript with php. Dont’ know what I was thinking.

  • Curtis Thompson

    May 4, 2005 at 9:13 pm

    hello…

    if it’s a post form, then you can get the variable from either the $_POST or $HTTP_POST_VARS array…if it’s a get form, then replace the “POST” in the above array names with “GET”…which of these to use depends on your version of php…the script likely uses them itself, so check for either of these…

    so assuming it’s a get form, you would do:

    if (!$subject) {
        $subject = “# of Attendees: {$_GET[“attendees”]}”; 
    }
    

    note 2 things:

    1. the “attendees” variable in the _GET array is the form field name for your attendees field

    2, the { and } brackets around the variable are so that you can have a variable with quotes in it inside a quoted string – you can also do it this way (same thing, but in theory a few millionths of a millisecond slower because the engine has to make a string buffer first):

    if (!$subject) {
        $subject = “# of Attendees: “.$_GET[“attendees”]; 
    }
    

    make sense?

    sitruc

  • Bret Williams

    May 5, 2005 at 3:10 am

    The form itself is a POST action. Should I also check within the script? If it’s post, then do I replace the $_GET in your script with $_POST or with $HTTP_POST_VARS if it’s the latest version of PHP. It’s at least 4.x.

  • Curtis Thompson

    May 5, 2005 at 3:30 am

    hello…

    whatever your form action is in the form is where you’ll find your variables – so if it’s a post method form, then they’ll be in either _POST or HTTP_POST_VARS…probably the latter in 4.x if i recall correctly…

    sitruc

  • Bret Williams

    May 5, 2005 at 4:33 am

    Yep. It was the latter. Thanks so much. I added another field too, their name. It’s an online rsvp. I couldn’t get the persons name into the from field with the email address, so I just put it in the subject… “RSVP : (name variable) # attendees (attendees variable)” and it’s great. With RSVP as the main subject heading it’s pretty easy to have a mail filter put them all in the same folder.

    The next step would be to have it write to a mysql database that could be viewed online and printed out. 🙂 Ok, that’s overkill.

    Thanks again!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy