pixeltrace Posted November 3, 2006 Share Posted November 3, 2006 guys,i need help.... how can i set my form in such a way that the sender must either fill upeither 1 of the 2 fields?examplename: company:email address:on my condition, email address is required but for name and company, he can either fill up just one of them.otherwise an error will appear.from this code what should i do here to fix my problem?thanks![code]echo "<CENTER>";if (($name == "") || ($company == "") || ($email == "")) {echo '<br><br><span class="bodytext3">Please complete the form. Thanks!</span><br>'; exit;}if(!email_is_valid($email)) {echo '<br><br><span class="bodytext3"><br>Email Address Invalid. <br>Please use a valid Email Address</span><br>';echo '<span class="bodytext3"><br>Thank You!</span><br>'; exit;}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/26075-need-help-on-form-required-fields-option/ Share on other sites More sharing options...
jpratt Posted November 3, 2006 Share Posted November 3, 2006 what if you tried adding a set of parens around your if statement like so and use the and operator instead:[code]if (($name == "") || (($company == "") && ($email == ""))) {[/code] Quote Link to comment https://forums.phpfreaks.com/topic/26075-need-help-on-form-required-fields-option/#findComment-119189 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.