legohead6 Posted April 2, 2006 Share Posted April 2, 2006 it wont work...heres the code [code]Code: if($first = NULL $last = NULL $gun = NULL $age = NULL $saying = NULL $email = NULL $phone = NULL $users = NULL $passs = NULL){ ......... [/code] how do i make it work? Link to comment https://forums.phpfreaks.com/topic/6370-ifvariable-null/ Share on other sites More sharing options...
play_ Posted April 2, 2006 Share Posted April 2, 2006 Not sure what youre trying to do. Im assuming comare. so here it goesif($first = NULL or$last = NULL or$gun = NULL or$age = NULL or$saying = NULL or$email = NULL or$phone = NULL or$users = NULL or$passs = NULL){ Link to comment https://forums.phpfreaks.com/topic/6370-ifvariable-null/#findComment-23044 Share on other sites More sharing options...
legohead6 Posted April 2, 2006 Author Share Posted April 2, 2006 im validating a form....i want it so if 1 or more of them is null then not to send the form....i have the rest of the code...just cant get that part Link to comment https://forums.phpfreaks.com/topic/6370-ifvariable-null/#findComment-23045 Share on other sites More sharing options...
play_ Posted April 2, 2006 Share Posted April 2, 2006 Then that should work but its not a good method.When the user presses submit, you should check like this.if(empty($username)) {echo "Must enter a username";$username = false;} else {escape_data($username);$username = TRUE;} Link to comment https://forums.phpfreaks.com/topic/6370-ifvariable-null/#findComment-23057 Share on other sites More sharing options...
Zane Posted April 2, 2006 Share Posted April 2, 2006 use the is_null() function[code]if(is_null($var) || is_null($anotherVar))[/code] Link to comment https://forums.phpfreaks.com/topic/6370-ifvariable-null/#findComment-23058 Share on other sites More sharing options...
wildteen88 Posted April 2, 2006 Share Posted April 2, 2006 You'll want to code your if statement like so:[code]if(is_null($first) || is_null($last) || is_null($gun) || is_null($age) || is_null($saying) || is_null($email) || is_null($phone) || is_null($users) || is_null($pass)){ echo "Please fill in all fields!";}else{ //process form data}[/code] Link to comment https://forums.phpfreaks.com/topic/6370-ifvariable-null/#findComment-23102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.