/    Sign up×
Community /Pin to ProfileBookmark

Making fields required in a formmail script

I’m trying to add code to a formmail program to require the user to fill in the your_name, phone, and email fields but I don’t know how to format the code correctly in php. Can anyone show me what I need to change?

[code]
$valid_form = true;

if(isset($_POST[‘your_name’]) && empty($_POST[‘your_name’]))
or
if(isset($_POST[‘phone’]) && empty($_POST[‘phone’]))
or
if(isset($_POST[’email’]) && empty($_POST[’email’]))

{
$valid_form = false;
}

if(valid_form)
header(“Location: http://yourdomain.com/thankyou.html”);
else header(“Location: http://yourdomain.com/error.html”);
[/code]

Thanks.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@kiwibritSep 30.2007 — Drop 'validate form php' into Google.
×

Success!

Help @cybergrrl spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...