Hey umm how do you write a form that e-mails to you?
I so far have created a form and some labels and textboxes
Here is the code:
[HTML]<form name="contact" id="contact" method="put" action"#">
<label>Name: </label>
<p>
<input type="text" name="name" tabindex="1" class="ina"/>
</p>
<label>E-mail: </label>
<p>
<input type="text" name="email" tabindex="2" />
</p>
<label>Subject:</label>
<p>
<input type="text" name="subject" tabindex="3" />
</p>
<label>Message:
<p>
<textarea name="message"></textarea>
</p>
</label>
<p>
<input type="submit" name="Submit" value="Submit" tabindex="5" />
</p>
</form>[/HTML]
I would like to do a couple of things, first off make E-mail and Subject required, so that when a user presses Submit and if E-mail or Subject is not filled then a window pops up asking to fill in the all required fields.
Secondly, when the user presses submit I would like a message to be sent to an e-mail address(Example: support@coolkkids.com). The e-mail should be sent with all of the input the user provides.
Thank you any1 for their help.
25 14790
To send an email you are going to need a server side scripting language like PHP or ASP. Are you able to run either? You can google for a script or we can post an example.
HTH,
Aric
OK, umm i tried googling it didnt work, or im just really sucky at it.
So if u could put up an exapmle tat would be great
thank you
Does your web server support server side scripting languages such as PHP, PERL, JSP or ASP? If not, then an email form is not possible.
Does your web server support server side scripting languages such as PHP, PERL, JSP or ASP? If not, then an email form is not possible.
Luckily my web hosting site hostmonster.com does support CGI, Ruby (RoR), Perl, PHP, MYSQL
Usually it is against my principle to show complete code in the forum, but this time I will make an exception. Especially since this answer really belongs in the PHP forum. The following sample shows a simple contact-me email form by Charles Reace. This code has ample comments, so you can work it out for your own requirements. Good luck![php]<?php
################################################## ###############################
#
# mail.php - general-purpose email form and script
#
# copyright June 2005 by Charles Reace
#
# This software available as open source software under the Gnu General Public
# License: http://www.gnu.org/licenses/gpl.html
#
################################################## ##############################
################################################## ##############################
# user-defined variables - update for your email address(es) ################################################## ##############################
# home page for link at top of page:
$home = "http://www.yourdomain.com/";
# Modify the following variables to set up where emails will be sent.
# $toName will be concatenated with a "@" and then $toDomain to create
# the complete email address.
$toName = "johndoe"; # the part that goes before the @
$toDomain = "yourdomain.com"; # the part that comes after the @
# uncomment and edit the next two lines if you want to cc someone:
$ccName = "ccname";
$ccDomain = "ccdomain.com";
# uncomment and edit the next two lines if you want to bcc someone:
$bccName = "bccname";
$bccDomain = "bccdomain.com";
#################################
# end of user-defined variables
##################################
# email address validation function
# kudos to http://iamcal.com/publish/articles/php/parsing_email/pdf/
function is_valid_email_address($email) {
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
'\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
$quoted_pair = '\\x5c\\x00-\\x7f';
$domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
$quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
$domain_ref = $atom;
$sub_domain = "($domain_ref|$domain_literal)";
$word = "($atom|$quoted_string)";
$domain = "$sub_domain(\\x2e$sub_domain)*";
$local_part = "$word(\\x2e$word)*";
$addr_spec = "$local_part\\x40$domain";
return preg_match("!^$addr_spec$!", $email) ? 1 : 0;
}
# Init. some variables:
$error = "";
$success = FALSE;
# process form if submitted:
if(isset($_POST['submit'])){
foreach($_POST as $key => $val) {
if (empty($_POST[$key])) {
$error .= "You must enter a value for " .
ucwords(str_replace("_"," ",$key)) . ". ";
}
else {
if(get_magic_quotes_gpc()) {
$_POST[$key] = stripslashes($val);
}
}
if($key != 'message') {
$_POST[$key] = preg_replace('/[\r\n]/', ' ', $val);
}
}
if($_POST['email_address'] != $_POST['repeat_email']) {
$error .= "Email Address is not the same as Repeat Email. ";
}
elseif(is_valid_email_address($_POST['email_address']) == 0) {
$error .= "'{$_POST['email_address']}' does not appear to be a valid email address. ";
}
if(empty($error)) # no errors in input, so go ahead and email it.
{
$to = "$toName@$toDomain";
$headers = "From: ".preg_replace('/[\r\n]+/',' ', $_POST['email_address']);
if(!empty($ccName) and !empty($ccDomain)) {
$headers .= "\r\nCc: $ccName@$ccDomain";
}
if(!empty($bccName) and !empty($bccDomain)) {
$headers .= "\r\nBcc: $bccName@$bccDomain\r\n\r\n";
}
$headers .= "\r\nX-Mailer: PHP/" . phpversion();
$msg = "From {$_POST['name']} ({$_POST['email_address']})";
$msg .= "\n\n\n{$_POST['message']}";
echo "<pre>$headers"; exit;
$result = @mail($to,
stripslashes($_POST['subject']),
$msg,
$headers);
if(!$result) {
$error = "There was an unknown error while attempting to send your email.";
}
else {
header("Location: http://www.charles-reace.com/Email_Me/thanks.php");
}
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>
<title>Email Me</title>
<style type="text/css">
body {background-color:lemonchiffon;color:#002200;margin:10px 150px 0 150px; font-family:verdana,arial,sans serif;font-size:12px;}
.lab {margin-left:3px;display: block; float: left; width: 9em;}
legend {font-size:13px;font-weight:bold;}
</style>
</head>
<body>
<?php
if(!empty($error)){
echo "<p style='color: #c03;'>$error</p>\n";
}
?>
<h2>Email Me</h2>
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method=post>
<fieldset>
<legend>Your Contact Information</legend>
<p><label for='name' class='lab'>Name:</label>
<input type='text' name='name' id='name' size='30' maxlength='40'<?php
if(!empty($_POST['name'])){
echo "value='{$_POST['name']}'";
}
?>></p>
<p><label for='email_address' class='lab'>Email Address:</label>
<input type='text' name='email_address' id='email_address' size='30' maxlength='40'<?php
if(!empty($_POST['email_address'])){
echo "value='{$_POST['email_address']}'";
}
?>></p>
<p><label for='repeat_email' class='lab'>Repeat Email:</label>
<input type='text' name='repeat_email' id='repeat_email' size='30' maxlength='40'<?php
if(!empty($_POST['repeat_email'])) {
echo "value='{$_POST['repeat_email']}'";
}
?>></p>
</fieldset>
<p> </p>
<fieldset>
<legend>Message</legend>
<p><label for='subject' style="margin-left:3px;display: block; float: left; width: 9em;">Subject:</label>
<input type='text' name='subject' id='subject' size='50' maxlength='60'<?php
if(!empty($_POST['subject'])){
echo " value='{$_POST['subject']}'";
}
?>></p>
<p><label for='message' style="margin-left:3px;display: block; float: left; width: 9em;">Message:</label>
<textarea name='message' id='message' cols='50' rows='8'
style="width: 375px"><?php
if(!empty($_POST['message'])){
echo $_POST['message'];
}
?></textarea></p>
<p style="text-align: center;"><input type='submit' name='submit' value="Send Email"></p>
</fieldset>
</form>
</body>
</html>[/php]
Ronald :cool:
I was going to post one but that is more complete than the one I use
Well, I guess that will work (like I know!!!::sarcasm::)
I guess no harm in trying it out. Will tell you my results on Thursday.
If you have questions/problems with that posted code sample, it is probably a good idea to post them in the PHP forum.
Not that I would want to lure you away from this forum, but it is likely that there are more PHP people in the php forum. So help will be quicker.
Ronald :cool:
If you have questions/problems with that posted code sample, it is probably a good idea to post them in the PHP forum.
Not that I would want to lure you away from this forum, but it is likely that there are more PHP people in the php forum. So help will be quicker.
Ronald :cool:
Maybe I should start hanging out in there if it's a happening place.
Well even though its not Thursday yet.
I copied the code and pasted it and I dont think it worked.
The link is cppinquiry.codetuts.com/contact.html
So wat do i do?
You didn't include that on your page correctly. The problem is you have basically two HTML pages in one.
UMM so how do i make it one?
UMM so how do i make it one?
Don't include the second - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-
<html lang='en'>
-
<head>
-
<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>
-
<title>Email Me</title>
-
<style type="text/css">
-
etc....
-
-
Only include the form below this and the php above this.
i did do that but now its even more messed up
Post the page minus the php we gave you and we will re-post it with the correct code.
Aric
this is the original code w/o
my form itself -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
-
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-
<head>
-
<title>Codetuts-CppInquiry</title>
-
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
-
<meta name="description" content="Your description goes here." />
-
<meta name="keywords" content="your,keywords,goes,here" />
-
<meta name="author" content="Brett Hillesheim" />
-
<link rel="stylesheet" href="css.css" type="text/css" media="screen" />
-
<link href="/contact.css" rel="stylesheet" type="text/css" media="screen" />
-
</head>
-
-
<body>
-
<div id="container">
-
<div id="sitename">
-
<h1>Codetuts-CppInquiry</h1>
-
-
</div>
-
-
<div class="tabsF" id="tabsF" dir="ltr" lang="en" onclick="http://www.codetuts.com
-
">
-
<ul>
-
<li><a href="index.html" title="CppInquiry"><span>Home</span></a></li>
-
<li><a href="programs.html" title="Programs/Source"><span>Programs/Source</span></a></li>
-
<li><a href="construction.html" title="Tutorials"><span>Tutorials</span></a></li>
-
<li><a href="construction.html" title="Articles"><span>Articles</span></a></li>
-
-
<li><a href="construction.html" title="Forum"><span>Forum</span></a></li>
-
<li><a href="http://www.codetuts.com" title="Codetuts.com"><span>Codetuts</span></a></li>
-
<li class="linklist"><a href="construction.html" title="Archives"><span>Archives </span></a></li>
-
<li><a href="#" title="Contact Us"><span>Contact Us</span></a></li>
-
</ul>
-
</div>
-
-
<div #tabsf>
-
<ul>
-
<il>
-
<a> <span></span></a>
-
</ul>
-
</div>
-
<div id="wrap">
-
<br/><br/>
-
<div id="rightside">
-
<h1>Links</h1>
-
<ul class="linklist">
-
<li><a href="http://www.omnamo.com">Omnamo</a></li>
-
<li><a href="construction.html">Gallery</a></li>
-
<li><a href="construction.html">Affiliates</a></li>
-
-
<li><a href="http://oswd.org">OSWD.org</a></li>
-
</ul>
-
-
-
<h1> </h1>
-
-
<h1>Latest Announcements</h1>
-
-
<div id="scroll2">
-
<p><strong>Year of 2006 </strong></p>
-
<p><strong>Dec.11: </strong>Creation of Codetuts-Sravan ftp site</p>
-
<p><strong>Dec.13: </strong>First uploading of the site's layout thanks to Brett7481</p>
-
<p><strong>Dec. 15:</strong> Change of name to CppInquiry </p>
-
<p><strong>Dec. 16: </strong>Programs/Source section is up</p>
-
<p><strong>Dec. 16: </strong>Created "Under Constructions" pages for CppInquiry</p>
-
</div>
-
<h1> </h1>
-
</div>
-
<div id="contentalt" >
-
<div id="scroll">
-
-
</div>
-
<p> </p>
-
</div>
-
-
<div class="clearingdiv"> </div>
-
</div>
-
-
<div id="footer">@2006 Codetuts-CppInquiry| Design by <a href="http://www.ibentmywookie.org">Brett7481</a></div>
-
</div>
-
</body>
-
</html>
-
I need the form in the part where it says
[HTML]<div id="contenalt">
<div id="scroll2">
</div>
<p> </p>
</div>[/HTML]
I need the form in the part where it says
[HTML]<div id="contenalt">
<div id="scroll2">
</div>
<p> </p>
</div>[/HTML]
Inbetween the paragraph tags?
no between the div tags.
the div tags make like a scrollbox for the main content. I would like it there.
Thnks a ton
I don't have your style sheet but try this: - <?php
-
################################################## ###############################
-
#
-
# mail.php - general-purpose email form and script
-
#
-
# copyright June 2005 by Charles Reace
-
#
-
# This software available as open source software under the Gnu General Public
-
# License: http://www.gnu.org/licenses/gpl.html
-
#
-
################################################## ##############################
-
################################################## ##############################
-
# user-defined variables - update for your email address(es) ################################################## ##############################
-
# home page for link at top of page:
-
$home = "http://www.yourdomain.com/";
-
# Modify the following variables to set up where emails will be sent.
-
# $toName will be concatenated with a "@" and then $toDomain to create
-
# the complete email address.
-
$toName = "johndoe"; # the part that goes before the @
-
$toDomain = "yourdomain.com"; # the part that comes after the @
-
# uncomment and edit the next two lines if you want to cc someone:
-
$ccName = "ccname";
-
$ccDomain = "ccdomain.com";
-
# uncomment and edit the next two lines if you want to bcc someone:
-
$bccName = "bccname";
-
$bccDomain = "bccdomain.com";
-
#################################
-
# end of user-defined variables
-
##################################
-
# email address validation function
-
# kudos to http://iamcal.com/publish/articles/php/parsing_email/pdf/
-
function is_valid_email_address($email) {
-
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
-
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
-
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
-
'\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
-
$quoted_pair = '\\x5c\\x00-\\x7f';
-
$domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
-
$quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
-
$domain_ref = $atom;
-
$sub_domain = "($domain_ref|$domain_literal)";
-
$word = "($atom|$quoted_string)";
-
$domain = "$sub_domain(\\x2e$sub_domain)*";
-
$local_part = "$word(\\x2e$word)*";
-
$addr_spec = "$local_part\\x40$domain";
-
return preg_match("!^$addr_spec$!", $email) ? 1 : 0;
-
}
-
# Init. some variables:
-
$error = "";
-
$success = FALSE;
-
-
# process form if submitted:
-
if(isset($_POST['submit'])){
-
foreach($_POST as $key => $val) {
-
if (empty($_POST[$key])) {
-
$error .= "You must enter a value for " .
-
ucwords(str_replace("_"," ",$key)) . ". ";
-
}
-
else {
-
if(get_magic_quotes_gpc()) {
-
$_POST[$key] = stripslashes($val);
-
}
-
}
-
if($key != 'message') {
-
$_POST[$key] = preg_replace('/[\r\n]/', ' ', $val);
-
}
-
}
-
if($_POST['email_address'] != $_POST['repeat_email']) {
-
$error .= "Email Address is not the same as Repeat Email. ";
-
}
-
elseif(is_valid_email_address($_POST['email_address']) == 0) {
-
$error .= "'{$_POST['email_address']}' does not appear to be a valid email address. ";
-
}
-
if(empty($error)) # no errors in input, so go ahead and email it.
-
{
-
$to = "$toName@$toDomain";
-
$headers = "From: ".preg_replace('/[\r\n]+/',' ', $_POST['email_address']);
-
if(!empty($ccName) and !empty($ccDomain)) {
-
$headers .= "\r\nCc: $ccName@$ccDomain";
-
}
-
if(!empty($bccName) and !empty($bccDomain)) {
-
$headers .= "\r\nBcc: $bccName@$bccDomain\r\n\r\n";
-
}
-
$headers .= "\r\nX-Mailer: PHP/" . phpversion();
-
$msg = "From {$_POST['name']} ({$_POST['email_address']})";
-
$msg .= "\n\n\n{$_POST['message']}";
-
echo "<pre>$headers"; exit;
-
$result = @mail($to,
-
stripslashes($_POST['subject']),
-
$msg,
-
$headers);
-
if(!$result) {
-
$error = "There was an unknown error while attempting to send your email.";
-
}
-
else {
-
header("Location: http://www.charles-reace.com/Email_Me/thanks.php");
-
}
-
}
-
}
-
?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
-
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-
<head>
-
<title>Codetuts-CppInquiry</title>
-
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
-
<meta name="description" content="Your description goes here." />
-
<meta name="keywords" content="your,keywords,goes,here" />
-
<meta name="author" content="Brett Hillesheim" />
-
<link rel="stylesheet" href="css.css" type="text/css" media="screen" />
-
<link href="/contact.css" rel="stylesheet" type="text/css" media="screen" />
-
</head>
-
-
<body>
-
<div id="container">
-
<div id="sitename">
-
<h1>Codetuts-CppInquiry</h1>
-
-
</div>
-
-
<div class="tabsF" id="tabsF" dir="ltr" lang="en" onclick="http://www.codetuts.com
-
">
-
<ul>
-
<li><a href="index.html" title="CppInquiry"><span>Home</span></a></li>
-
<li><a href="programs.html" title="Programs/Source"><span>Programs/Source</span></a></li>
-
<li><a href="construction.html" title="Tutorials"><span>Tutorials</span></a></li>
-
<li><a href="construction.html" title="Articles"><span>Articles</span></a></li>
-
-
<li><a href="construction.html" title="Forum"><span>Forum</span></a></li>
-
<li><a href="http://www.codetuts.com" title="Codetuts.com"><span>Codetuts</span></a></li>
-
<li class="linklist"><a href="construction.html" title="Archives"><span>Archives </span></a></li>
-
<li><a href="#" title="Contact Us"><span>Contact Us</span></a></li>
-
</ul>
-
</div>
-
-
<div #tabsf>
-
<ul>
-
<il>
-
<a> <span></span></a>
-
</ul>
-
</div>
-
<div id="wrap">
-
<br/><br/>
-
<div id="rightside">
-
<h1>Links</h1>
-
<ul class="linklist">
-
<li><a href="http://www.omnamo.com">Omnamo</a></li>
-
<li><a href="construction.html">Gallery</a></li>
-
<li><a href="construction.html">Affiliates</a></li>
-
-
<li><a href="http://oswd.org">OSWD.org</a></li>
-
</ul>
-
-
-
<h1> </h1>
-
-
<h1>Latest Announcements</h1>
-
-
<div id="scroll2">
-
<p><strong>Year of 2006 </strong></p>
-
<p><strong>Dec.11: </strong>Creation of Codetuts-Sravan ftp site</p>
-
<p><strong>Dec.13: </strong>First uploading of the site's layout thanks to Brett7481</p>
-
<p><strong>Dec. 15:</strong> Change of name to CppInquiry </p>
-
<p><strong>Dec. 16: </strong>Programs/Source section is up</p>
-
<p><strong>Dec. 16: </strong>Created "Under Constructions" pages for CppInquiry</p>
-
</div>
-
<h1> </h1>
-
</div>
-
<div id="contentalt" >
-
<div id="scroll">
-
-
<h2>Email Me</h2>
-
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method=post>
-
<fieldset>
-
<legend>Your Contact Information</legend>
-
<p><label for='name' class='lab'>Name:</label>
-
<input type='text' name='name' id='name' size='30' maxlength='40'<?php
-
if(!empty($_POST['name'])){
-
echo "value='{$_POST['name']}'";
-
}
-
?>></p>
-
<p><label for='email_address' class='lab'>Email Address:</label>
-
<input type='text' name='email_address' id='email_address' size='30' maxlength='40'<?php
-
if(!empty($_POST['email_address'])){
-
echo "value='{$_POST['email_address']}'";
-
}
-
?>></p>
-
<p><label for='repeat_email' class='lab'>Repeat Email:</label>
-
<input type='text' name='repeat_email' id='repeat_email' size='30' maxlength='40'<?php
-
if(!empty($_POST['repeat_email'])) {
-
echo "value='{$_POST['repeat_email']}'";
-
}
-
?>></p>
-
</fieldset>
-
<p> </p>
-
<fieldset>
-
<legend>Message</legend>
-
<p><label for='subject' style="margin-left:3px;display: block; float: left; width: 9em;">Subject:</label>
-
<input type='text' name='subject' id='subject' size='50' maxlength='60'<?php
-
if(!empty($_POST['subject'])){
-
echo " value='{$_POST['subject']}'";
-
}
-
?>></p>
-
<p><label for='message' style="margin-left:3px;display: block; float: left; width: 9em;">Message:</label>
-
<textarea name='message' id='message' cols='50' rows='8'
-
style="width: 375px"><?php
-
if(!empty($_POST['message'])){
-
echo $_POST['message'];
-
}
-
?></textarea></p>
-
<p style="text-align: center;"><input type='submit' name='submit' value="Send Email"></p>
-
</fieldset>
-
</form>
-
-
-
-
-
</div>
-
<p> </p>
-
</div>
-
-
<div class="clearingdiv"> </div>
-
</div>
-
-
<div id="footer">@2006 Codetuts-CppInquiry| Design by <a href="http://www.ibentmywookie.org">Brett7481</a></div>
-
</div>
-
</body>
-
</html>
Also you need to read the script there is information that you need to fill out in there like your email address.
There are a number of ways of doing this i.e. server side and client side. The suggestion below is client side using Javascript, this way you won't need a server to test it out, although you will for the second of your queries(some on to that later).
Right number 1: validating the form. You want to generate a pop up window when a user has not filled in a particular field. This is Javascript.
Here's what you do.
In the html change method="put" to "post"
<form method="post" id="contact" onsubmit="return checkall(this);" action="i'll come onto this later">
It's easiest to stick this your html rather than a separate file. In the 'Head' section use this.
<script type="text/javascript">
function checkall(contact)
{
if (contact.name.value == "")
{
alert("You must enter a name");
return (false);
}
if (contact.subject.value == "")
{
alert("You must enter your address");
return (false);
}
}
</script>
The code explained: 'function checkall(contact)' goes through the form validating whatever you have asked it to, in this script i.e. the name and subject fields.
'if (contact.name.value == "")' This says "if the contact form where the value of the field name is blank then print out the error message - which can say anything you want it to, if the fields are not blank then allow the form to be processed"
Number 2. This is where it gets a little more involved
In order to send the form, you'll need to use a 'sever side' language, in other words first of all you need to install a server. The server you use will depend upon which laguage you want to use to process the email. One such language is PHP, so rather than go through all the possibilities i'll stick to, how to do it using PHP.
PHP can be run on one of two servers, Apache or IIS.
The PHP code used to send the email
<?php
//these 'extract' the information written by the user from the name and subject fields
$name = $_REQUEST['name'] ;
$subject = $_REQUEST['subject'] ;
//sets the email address to send message from
ini_set("sendmail_from","the-email-address-you-want-to-use-to-send-the-email-from");
//takes the form "to-email address", "subject of the email", "then takes the 'subject and name' from the form"
mail("youremailaddressagain", "subject of message-Here's hoping this arrives, Fingers crossed!", "Comment:$subject", "From: $name");
//a little thankyou message
echo "A thankyou message-thankyou for message-or something";
?>
The backslashes are used as comments in the code and do not get processed.
Hope that helps! This is simple really, might not look it though.
wtf its not workin. I dont know what I'm doing wrong.
But anyways thanks and just want to point out that
when you go to the page cppinquiry.codetuts.com/contact.html
it starts to show some of the code starting from "$val"
So any suggesstions.
[quote=CMK]There are a number of ways of doing this i.e. server side and client side. The suggestion below is client side using Javascript, this way you won't need a server to test it out, although you will for the second of your queries(some on to that later).
Right number 1: validating the form. You want to generate a pop up window when a user has not filled in a particular field. This is Javascript.
Here's what you do.
In the html change method="put" to "post"
<form method="post" id="contact" onsubmit="return checkall(this);" action="i'll come onto this later">
It's easiest to stick this your html rather than a separate file. In the 'Head' section use this.
<script type="text/javascript">
function checkall(contact)
{
if (contact.name.value == "")
{
alert("You must enter a name");
return (false);
}
if (contact.subject.value == "")
{
alert("You must enter your address");
return (false);
}
}
</script>
QUOTE]
Ok first things first how does the computer know when to display the alert message and is "alert();" already defined somewhere (over the rainbow)!
And also can you explain "action" in the <form...>
Number 2. This is where it gets a little more involved
In order to send the form, you'll need to use a 'sever side' language, in other words first of all you need to install a server. The server you use will depend upon which laguage you want to use to process the email. One such language is PHP, so rather than go through all the possibilities i'll stick to, how to do it using PHP.
PHP can be run on one of two servers, Apache or IIS.
The PHP code used to send the email
<?php
//these 'extract' the information written by the user from the name and subject fields
$name = $_REQUEST['name'] ;
$subject = $_REQUEST['subject'] ;
//sets the email address to send message from
ini_set("sendmail_from","the-email-address-you-want-to-use-to-send-the-email-from");
//takes the form "to-email address", "subject of the email", "then takes the 'subject and name' from the form"
mail("youremailaddressagain", "subject of message-Here's hoping this arrives, Fingers crossed!", "Comment:$subject", "From: $name");
//a little thankyou message
echo "A thankyou message-thankyou for message-or something";
?>
The backslashes are used as comments in the code and do not get processed.
Hope that helps! This is simple really, might not look it though.
Now on to number too, are all those functions already defined (i.e ini_set(), mail())
Also what do the functions do, and what are the arguements according to my form(below) and my e-mail address "cppinquiry@codetuts.com"
[HTML]
<form method="post" id="contact" onsubmit="return checkall(this);" action="i'll come onto this later">
<label>Name: </label>
<p>
<input type="text" name="name" tabindex="1" class="ina"/>
</p>
<label>E-mail: </label>
<p>
<input type="text" name="email" tabindex="2" />
</p>
<label>Subject:</label>
<p>
<input type="text" name="subject" tabindex="3" />
</p>
<label>Message:
<p>
<textarea name="message"></textarea>
</p>
</label>
<p>
<input type="submit" name="Submit" value="Submit" tabindex="5" />
</p>
</form>
[/HTML]
heheh I stole ur form declaration heheheh
thanks for ur help
ill put ur name if u want in comments on this page, if you can help me with this goal
popnbrown are you still having problems with this?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jason |
last post by:
I'm struggling with this email code and I'm not php freak since I'm
starting to learn php stuff. Could use some help...
It seems that I get too many parse errors all over and cannot figure
went...
|
by: Steevo |
last post by:
For some reason I can't seem to get the contact form on our website to work
any longer. I think I must have something wrong in the script because I keep
getting an "Internal Server Error" upon...
|
by: Al Dykes |
last post by:
I'm going to be collecting lots (a few thousand) email addys. Each of
these people will be interested in recieving mail on one or more
topics, with an open ended and growing number of topics....
|
by: Serge Fournier |
last post by:
I would like to access the "contact" data in Outlook Express.
Which reference do I have to use ? (I was thinking at "Office").
Thanks
for any help
|
by: Matt |
last post by:
delicious has a bookmark you can add to your toolbar of this form:...
|
by: H5N1 |
last post by:
hi there
the topic says it all.
I have a outer join select statement in tableadapter that populates
GridView, I want to make it updatetable, so I need to provide an update
command for table...
|
by: popnbrown |
last post by:
Anyone know how to write PHP that can take values that a user inputs into a form on a webiste and the e-mail those values to myself. In other words how do i write PHP code for a Contact Us Form?
|
by: kang jia |
last post by:
how can i do contact us page? use mail function ??hmm.. but when i click "contact us" navigation. it will link the mailbox. how to do this linkage?
i am quite new to PHP, maybe this problem seems...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |