n1kki6 Posted July 19, 2011 Share Posted July 19, 2011 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. Link to comment https://forums.phpfreaks.com/topic/242338-help-with-form-variable-in-a-input-value/ Share on other sites More sharing options...
AyKay47 Posted July 19, 2011 Share Posted July 19, 2011 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]; Link to comment https://forums.phpfreaks.com/topic/242338-help-with-form-variable-in-a-input-value/#findComment-1244649 Share on other sites More sharing options...
n1kki6 Posted July 19, 2011 Author Share Posted July 19, 2011 Awesome, thank you. I will try it out. Link to comment https://forums.phpfreaks.com/topic/242338-help-with-form-variable-in-a-input-value/#findComment-1244762 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.