user2153920
user2153920

Reputation:

If formfield is not empty then stop execution of script

I have a contact form and it should send me an email with content using php mail.

To avoid some spambots I have a hidden field in the form.

Now I want to check if the field is empty, and if not stop the script from sending the mail.

I request the content of the field into the $bot variable

So what I want to to is something like

if $bot not empty then don't go on else execute the rest of the script

Please help a beginner

Regards

Anders

Upvotes: 0

Views: 253

Answers (2)

adeel iqbal
adeel iqbal

Reputation: 494

you can use JAVASCRIPT. it would definitely be helpful to apply anytype of checks you want.

if you only use the php code on the next page. then it would not be a good strategy.

Upvotes: 0

evuez
evuez

Reputation: 3387

Use the empty() function:

<?php
if (empty($bot)) {
    // send your mail here
} else {
    // redirect, the field is not empty!
}
?>

Upvotes: 1

Related Questions