Jump to content

Recommended Posts

Hi Everyone, 

 

I have a basic php form created that for some upcoming events that I am having.  I collect the basic information and also have some radio buttons to select the location you will be attending.  This then send an e-mail confirmation to the registrant and then a few of my associates. 

 

Here is what I am trying to figure out.

 

The events are held in different states.  So when the person select the location they will attend I woud like to include the state name in the subject lin of the e-mail.

 

Below is the code I am using.

 

My Variable for the event.

 

$event = $_POST['event'];

 

My input on the form

 

<input type="radio" name="event" value="September 8, 2011 - Holiday Inn Jordan Creek - West Des Moines, IA">

 

The line of code I use on my e-mail confirmation

 

$body .= "<b>Event:</b> ".$event."<br /><br />";

 

What I would like is to make the IA for example a variable that I can include in the subject line of the e-mailm but the state will change depending on the lacation selected.  So if they select an MN event is show MN in the e-mail subject line.

 

So far I have come up with including a variable in the input value but I am not sure how to make it change for each location.

 

<input type="radio" name="event" value="September 14, 2011 - Northland Inn - Brooklyn Park, <?php echo $state2; ?>">

 

 

Any help or direction would be greatly appreciated.

you should be able to use a simple preg_match here to isolate the state name in each radio button value..

 

$event = $_POST['event'];
$pattern = '~([A-Z]{2})~';
preg_match($pattern, $event,$matches);
$state_abbrev = $matches[0];

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.