Forum Moderators: open

Message Too Old, No Replies

Online Application Form

application form for school

         

bluebarney

6:50 pm on Nov 21, 2005 (gmt 0)

10+ Year Member



I've just started to run the website for my small language school and want to include an online application form.

I have had a go at building it (with Dreamweaver) but don't know how to design it so that when a potential student presses SUBMIT, the form will arrive in my email inbox. Any ideas?

Hope that makes sense!

Robin_reala

7:24 pm on Nov 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need to use some serverside language. Here's an example of a contact form I wrote for my site in PHP:

<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

$name = htmlentities($_POST['name']);
$email = htmlentities($_POST['email']);
$comment = htmlentities($_POST['comment']);

$subject = 'Website contact from ' . $name . ' (' . $email . ')';

$sent = mail("example@example.com", $subject, $comment, $email);
}

?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Contact me</title>
</head>
<body>
<?php

if ($_SERVER['REQUEST_METHOD'] == 'GET') {

echo ('<form action="');
echo $_SERVER['PHP_SELF'];
echo ('" method="post">');
echo ('<fieldset><label for="name">Name:</label><input type="text" id="name" name="name" />
<label for="email">Email:</label><input type="text" id="email" name="email" />
<label for="comment">Comment:</label><textarea id="comment" name="comment" rows="4" cols="20"></textarea>
<input type="submit" value="Submit" class="submit" />
</fieldset>
</form>');

}elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {

if ($sent == 'TRUE') {
echo ('<p>Thanks! Your message has been successfully sent.</p>');
}

elseif ($sent == 'FALSE') {
echo ('<p>There was a problem sending your mail. Try contacting me directly at <a href="mailto:example@example.com">example@example.com</a>.</p>');
}
}

?>

</body>
</html>

It's pretty selfcontained: if the page is being requested normally then it writes out a form, but if it's being submitted to then it sends the mail and writes out a thankyou.

(n.b. my PHP skills are limited at best, so if anyone else wants to debug this go ahead. It seems to work for me though)

tedster

7:41 pm on Nov 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums, bluebarney.

Are you using a third party host? Many commercial services today have a generic form set-up that you can just tweak to your own particular needs -- bypassing the issue of writing your own script. If you are on a commercial web host, it would be good to ask.

Mail scripts are usually written in PERL or PHP -- but many hosts already have it working on their server. So they can give you simple instructions on how to adapt the basic setup and you can bypass the learning curve.

bluebarney

11:33 am on Nov 22, 2005 (gmt 0)

10+ Year Member



Thanks to both of you for your help and advice. I think I even understand some of it!