/    Sign up×
Community /Pin to ProfileBookmark

A newbie needing some help from you guys (aka: The Legends) :D

Ok guys, I’ve been doing a contact form, and have got some simple questions (simple for you guys, I’ve been struggling for days!)

Number 1: How do I make a contact form ensure all the boxes are filled in?
Number 2: How can I create a little pop-up that says if all the boxes AREN’T filled in?

Number 3: How can I get my PHP mailing form to redirect back to the main page, after a successful submit?

Below is the coding for the PHP form, and a bit of the HTML coding on the contact page.

Thanks in advance guys, and a beer to the first one to help me ?

PHP FORM:

[quote]

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd“>
<html>
<head>
<title>Enquiry Submitted</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>

<body>
<?php
if(isset($_POST[‘submit’])) {

$to = “sales@*********”;
$subject = “Website Enquiry”;
$name_field = $_POST[‘name’];
$email_field = $_
POST[’email’];
$message = $_POST[‘message’];

$body = “From: $name_fieldn E-Mail: $email_fieldn Message:n $message”;

echo “Thank you for submitting your enquiry, you will be rediverted back to the main page in 5 seconds”;
mail($to, $subject, $body);

} else {

echo “Error, your message has not been sent. Sorry.!”;

}
?>

<p>Please click <a href=http://www.**************>here</a> if you are not re-diverted.

</body>
</html>

[/quote]

HTML FORM:

[quote]

<form method=”POST” action=”mailer.php”>
<input type=”text” name=”name” size=”19″>
<br>
</p>
<p>
<input type=”text” name=”email” size=”19″>
</p>
<p><br>
<br>
<textarea rows=”9″ name=”message” cols=”30″></textarea>
<br>
<br>
<input type=”submit” value=”Submit” name=”submit”>
</form>

[/quote]

Once again, thanks for taking the time to read my thread, I really appreciate it.

Matt

to post a comment
PHP

0Be the first to comment 😎

×

Success!

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