Jump to content

Help with Form Variable in a Input Value


n1kki6

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];

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.