Phpfanboi Posted January 26, 2011 Share Posted January 26, 2011 <FORM METHOD=POST ACTION=""> <p>Breeder or Business Name<br /> <input type = "text" name = "breedername" size= "25" maxlength = "50" /> </p> <p>Breeder Telephone<br /> <input type = "text" name = "breedertelephone" size= "25" maxlength = "50" /> </p> <p>Breeder Location<br /> <input type = "text" name = "breederlocation" size= "25" maxlength = "50" /> </p> <p>Breeder Desription<br /> <input type = "text" name = "breederdescription" size= "25" maxlength = "50" /> </p> <p>Leave blank<br /> <input type = "text" name = "breederverify" size= "5" maxlength = "5" /><br /><br /> </p> <input type="submit" value="Submit" name='submit' /> <br /> <br /> </form> <?php if (is_string($breederverify)) { <-- If $breederverify is set , then echo "Please leave the lowest box empty!" echo "Please leave the lowest box empty!"; } else { <-- else if $breederverify is unsigned/null execute this block. $con = mysql_connect("localhost","xxxxxxxxxx","xxxxxxxxxx"); mysql_select_db("cichlid",$con); $breedername = $_POST['breedername']; $breedertelephone = $_POST['breedertelephone']; $breederlocation = $_POST ['breederlocation']; $breederdescription = $_POST ['breederdescription']; $breederverify = $_POST ['breederverify']; $sql = "INSERT INTO breedersinfo SET breederNAME = '$breedername' , breederTELEPHONE = '$breedertelephone' , breederLOCATION = '$breederlocation' , breederDESCRIPTION = '$breederdescription'"; if(!mysql_query($sql,$con)) { die('ERROR:Could not connect ' . mysql_error ()); } echo ""; mysql_close ($con) ; } ?> All i am trying to accomplish is a form field that will only update records if the last $breederverify = $_POST ['breederverify']; is null/unasigned . I was thinking in order to do this i could use is_numeric , or is_string function to check $var ,to see what it's state is. Any help or advice would be appreciated , provided this is even possible. Cheers guys . Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 26, 2011 Share Posted January 26, 2011 yes, you can check that server-side to check it client-side you would need to incorporate some javascript Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted January 26, 2011 Share Posted January 26, 2011 Posted values are always strings even if they are empty strings, but it also may be 0 which is considered empty. Use this: if (!empty($breederverify) || $breederverify == '0') { echo "Please leave the lowest box empty!"; Quote Link to comment Share on other sites More sharing options...
Phpfanboi Posted January 27, 2011 Author Share Posted January 27, 2011 Posted values are always strings even if they are empty strings, but it also may be 0 which is considered empty. Use this: if (!empty($breederverify) || $breederverify == '0') { echo "Please leave the lowest box empty!"; Cheers Mate Quote Link to comment 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.