Jump to content
Larry Ullman's Book Forums

Removing White Space From Email Submission

Recommended Posts

I want to create a contact form that has an email field where the user can't enter any white space in the field, for example: test@ex ample.com

I am using a spam scrubbing function taught to us in the book to clean user inputs. 

I am using my variable like so.

$email = strip_tags($scrubbed['email']);


how can I add something like this $email = preg_replace('/\s+/', '', $email);

to the existing $email = strip_tags($scrubbed['email']);


I tried 

$email = (preg_replace('/\s+/', '', $email)(strip_tags($scrubbed['email'])));


and all sorts of variations to that. it doesn't work. 

Link to comment
Share on other sites


  • Create New...