/    Sign up×
Community /Pin to ProfileBookmark

Form checking

Hello everyone. I’m a bit of a newb, so please be kind.

Anyway, I am writing a simple script that will send an e-mail from information gathered through a form. I realize there are probably [B]numerous[/B] scripts already made online, but I would like to do this myself.

What I need to know is how would I redirect a user to an error page if not all fields in the form have information? I’m pretty sure I’ve got how to check if all the fields are filled out or not, but I don’t know how I would redirect them to the error page. Can someone help me out please?……….Lan

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ConorApr 10.2005 — [code=php]if($formelement1=="" || $formelement2=="" || $formelement3==""){header("Location:http://mysite.com/error.php");}[/code]
Copy linkTweet thisAlerts:
@NogDogApr 10.2005 — The other typical option is to do it all in the same file:
[code=php]
<html>
...common HTML...
<?php
# validate input fields, then...
if(<validation_is_ok>)
{
# process the data and send the email
# output a success message
}
else
{
# output appropriate error message(s)
}
?>
...common HTML...
</body>
</html>
[/code]
×

Success!

Help @Lan 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,
)...