FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Forms?





Unzoomed
Hello

I dont really know where to put this so lets take it here..

I want to do a form and when you press the supmit button an mail will be sent to me with the information from the form, so how do I do this? and can I do it in html or do i have to use asp or php or something else?.. I've heard something about that you should use a cgi server but I've never gotten any good answer on how to do it so plz help me...

Thanks in advance

/Unzoomed
wumingsden
just fount a very simplistic form on my hosting account. You can see it at www.mezmorizing.net/test/contact/contact.php
*note - I have not tried the code, so held no responsibility as to what might happen.
*also note - name the file *some_name*.php

Here's the code (change the parts that it tells you to):

Code:

<?php

$to = "you@yoursite.com"; //Change to your e-mail address
$subject = "Feedback"; //Change to the subject of the emails you will get

if(isset($_POST['message']))
 {
 $msg = $_POST['message'];
 $email = $_POST['email'];
 $name = $_POST['name'];
 mail($to, $subject, $msg);
 }

$thisdoc = $_SERVER['PHP_SELF'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Contact Form</title>
</head>

<body>

<?php

if(!isset($_POST['message']))
 {
 print "<form action=\"$thisdoc\" method=\"post\">\n\n";
 print "Your name:<br />\n";
 print "<input type=\"text\" size=\"60\" name=\"name\"><br /><br />";
 print "Your e-mail address:<br />\n";
 print "<input type=\"text\" size=\"60\" name=\"email\"><br /><br />";
 print "Your message:<br />\n";
 print "<textarea name=\"message\" cols=\"60\" rows=\"4\">";
 print "</textarea><br /><br />";
 print "<input type=\"submit\" value=\"Send!\">";
 }

else if(isset($_POST['message']))
 {
 print "Thank you for your input!<br /><br />";
 print "Your message will be recieved shortly";
 }

?>

</body>
</html>
Unzoomed
Thank you, that worked perfectly Smile... now I just need to learn php to extend it a bit.. Smile... but that wont be to hard, hopefully xD
Kelcey
mmm. If you could get access to coldfusion, it's fairly easy. But that php example doesn't look bad at all either Razz
Related topics
basic tutorials on most forms of web programming
"Forms To Go" create scripts in PHP, ASP and Perl
Easily create forms and many other stuff without much knowle
Multiple Forms
I have a question regarding forms and such.
Anyone that can give me help/suggestions for forms?
Flash Tutorials
Building Web Forms In Flash
a question about forms. [SOLVED]
Question about forms on websites?
I am having alot of trouble with forms! Urgent help please!
PHP Forms security
Forms
Did earth's life forms come from Mars?
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.