rlineker Posted December 13, 2006 Share Posted December 13, 2006 I am making a contact form for my website and I am wondering how i can do this:send people to contact.php?act=" " and that has a certain drop down selection selected.Ryan Link to comment https://forums.phpfreaks.com/topic/30536-php-contact-form/ Share on other sites More sharing options...
OOP Posted December 13, 2006 Share Posted December 13, 2006 I did not understand what you are trying to do....would you please clarify more? Link to comment https://forums.phpfreaks.com/topic/30536-php-contact-form/#findComment-140568 Share on other sites More sharing options...
Caesar Posted December 13, 2006 Share Posted December 13, 2006 Can you be a little more specific? Or maybe post some of your existing code. This forum isn't really for providing people with scripts but we can definitely try and point you in the right direction.If you're not sure where to start, try looking at PHP's [url=http://us2.php.net/mail]mail()[/url] function. Link to comment https://forums.phpfreaks.com/topic/30536-php-contact-form/#findComment-140570 Share on other sites More sharing options...
rlineker Posted December 13, 2006 Author Share Posted December 13, 2006 I have made a contact form. I want to be able to send people to a link for example url.com/contact.php?act="posting" and url.com/contact.php?act="design". On the the contact page there is a drop down menu with the subject which are posting and design. I want it that when you have the act="posting" posting is selected in the drop down box.Ryan Link to comment https://forums.phpfreaks.com/topic/30536-php-contact-form/#findComment-140572 Share on other sites More sharing options...
OOP Posted December 13, 2006 Share Posted December 13, 2006 there are so many ways to do that . One simple solution is that you can do some sort of check in your contact page...somthing like below$option1 = '';$option2 = '';if($_GET['act'] == 'design'){ $option1 = 'selected';}elseif($_GET['act'] == 'posting'){ $option2 = 'selected';}then in your drop down list you can do thisecho '<select name="act"> <option value="design" $option1>design</option> <option value="posting" $option2>posting</option> </select>'; Link to comment https://forums.phpfreaks.com/topic/30536-php-contact-form/#findComment-140578 Share on other sites More sharing options...
Caesar Posted December 13, 2006 Share Posted December 13, 2006 Or.....[code]<?php $akshun = $_GET['act']; $select = ''; $doptions = array('design', 'posting'); echo"<select name=\"dropdown\">"; foreach($doptions as $option) { if($option == $akshun){$select = 'selected';} echo"<option value=\"$option\" $select>$option"; } echo"</select>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/30536-php-contact-form/#findComment-140581 Share on other sites More sharing options...
The Little Guy Posted December 13, 2006 Share Posted December 13, 2006 [code]<?php$slected = $_GET['act']; #get your var from the URL$options = array('posting','contact','question'); #list of menu itemsecho'<select name="dropdown">';foreach($options as $option){ echo'<option name="'.$option.'"'; if($option == $slected){echo' selected';} echo'>'.$option."</option>\n";}echo'</select>';?>[/code] Link to comment https://forums.phpfreaks.com/topic/30536-php-contact-form/#findComment-140589 Share on other sites More sharing options...
alpine Posted December 13, 2006 Share Posted December 13, 2006 *LOL* - this seems to be a competition ;DMy favourite way:[code]<?php$option = "";$options = array("design","posting");foreach ($options as $value){ $_GET['act'] == $value ? $sel = " selected=\"selected\"" : $sel = ""; $option .= "<option value=\"$value\"$sel>".ucfirst($value)."</option>";}echo <<<_SELECT<select name="act">$option</select>_SELECT;?>[/code] Link to comment https://forums.phpfreaks.com/topic/30536-php-contact-form/#findComment-140592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.