New to PHP. Tried using unset, was able to remove the phone number field visually. But if user fills out form and hits send, it results in an error message: "Attention! Phone number can only contain digits." Probably an easy fix, just can't wrap my head around it. Any tips? Thanks.

2 answers

1
point

Hacky fix, but why not edit the html form and include a hidden phone field with a numeric value.

You didn't say if you're writing the PHP script yourself or using a processor you found somewhere. the full fix of course would be to remove all references to the phone field in the error checking.

e.g. remove this and it won't care that the empty phone field isn't numeric:

else if(!is_numeric($phone)) {
                echo '<div class="error_message">Attention! Phone number can only contain digits.</div>';
                        exit();
        }

Ideally the form processor should check first for empty fields, then for validity of content, it might do that elsewhere in the code, but unsetting it probably didn't help.

Also, PHP questions would probably get better answers on stackoverflow.com, but I've tried to help...

Answered almost 6 years ago by Tony Crockford
0
points

Thanks for the assist!

Answered almost 6 years ago by Victor De Anda