Noctagon Posted September 25, 2006 Share Posted September 25, 2006 Hi All,I am totally new to this stuff so thanks in advance for your patience :)I am trying to run a simple if statement and it is not working as plan. Perhaps someone could tell me why :)I have a drop box weaved into my code as follows[code]<select size="1" name="nomtacyn"> <option selected>No</option> <option>Yes</option> </select>[/code]the form action is to run this[code]<?php $nomtacyn = $_POST['nomtacyn']; $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];?><html><head></head><body><?php if ($nomtacyn = No) { echo "Your have selected No"; } else { Echo "You have selected yes"; } ?></body></html>[/code]Thanks :) Quote Link to comment https://forums.phpfreaks.com/topic/22044-solved-if-drop-box/ Share on other sites More sharing options...
AndyB Posted September 25, 2006 Share Posted September 25, 2006 Try recoding your form (which presumably uses the method="post") thus:[code]<select size="1" name="nomtacyn"><option value="No" selected="selected">No</option><option value="Yes">Yes</option></select>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22044-solved-if-drop-box/#findComment-98610 Share on other sites More sharing options...
HuggieBear Posted September 25, 2006 Share Posted September 25, 2006 Your IF needs two '=' signs and quotes " "...if ($nomtacyn == "No"){RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22044-solved-if-drop-box/#findComment-98611 Share on other sites More sharing options...
Noctagon Posted September 25, 2006 Author Share Posted September 25, 2006 Thanks for the speedy reply.......doh.....I said to myself that double equals sign will never get me ;)Cheers Quote Link to comment https://forums.phpfreaks.com/topic/22044-solved-if-drop-box/#findComment-98614 Share on other sites More sharing options...
HuggieBear Posted September 25, 2006 Share Posted September 25, 2006 It would also be a good idea, as Andy suggested, to out values in your <option> tags, rather than just letting them take the value of the text.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22044-solved-if-drop-box/#findComment-98619 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.