•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Site Layout and Usability section within the Web Development category of DaniWeb, a massive community of 423,433 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,670 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Site Layout and Usability advertiser: Programming Forums
Views: 1234 | Replies: 3
![]() |
•
•
Join Date: Jun 2008
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Hello. I have a form page that has been created with the fields: Name, Email, Phone (day), Phone (Eve), Address, and Comments. The form will need to be sent to an email address upon clicking the submit button. I have read some previous posts and tried using some of the code suggested with the code below being one that worked for another user. When I go to the testing server to test the form I get an htdocs/missing.htm page instead of the form being submitted or giving a form not submitted error message. Could there be a problem with the permissions of the file, or am I missing something with the code? Thanks.
Here is the code:
Here is the code:
PHP Syntax (Toggle Plain Text)
<!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"> <head> <title> - City Hall Directory</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <form id="form1" method="post" action="<?php echo $me;?>"> <p><span class="style6">Name </span><br /> <input name="textfield" type="text" class="form" /> </p> <p><span class="style6">Email </span><br /> <input name="textfield2" type="text" class="form" /> </p> <p><span class="style6">Phone (day) </span><br /> <input name="textfield3" type="text" class="form" /> </p> <p><span class="style6">Phone (eve) </span><br /> <input name="textfield4" type="text" class="form" /> </p> <p><span class="style6">Address </span><br /> <input name="textfield5" type="text" class="form" /> </p> <p><span class="style6">Comments </span><br /> <textarea name="textfield6" cols="50" rows="10" class="form"></textarea> </p> <p> </p> <p> <input name="Submit" type="submit" class="form" value="Send" /> </p> </form> <? $formgood = true; $name = $_POST['Name']; $email = $_POST['Email']; $phone day = $_POST['Phone (day)']; $phone eve = $_POST['Phone (eve)']; $addfress = $_POST['Address']; $comments = $_POST['comments']; $to = "email@domainname.com"; //Please change this to your e-mail address $message = "$name has submitted a contact form. \n\n $comments \n\n You can reply to $email"; //check to make sure all form elements were filled in if ($name == "") { echo 'You must provide your name to contact us. Please click the back, and try again'; $formgood = false; } if ($email == "") { echo 'We require an e-mail address in order for us to respond. Please go back and try again.'; $formgood = false; } if ($comments == "") { echo 'You must provide comments in order to submit this form. Please click back, and try again.'; $formgood = false; } if ($formgood) { if(mail($to, "A contact us form has been submitted by $name", $message, "From: $email\n")) { echo 'Thank you for submitting this form. We will review your comments and contact you shortly. <br>'; } else { echo "An error has occured. Please contact the webmaster."; } } else { echo "<br> Please review the comments above and try again."; } ?> <p><br /> </p> <p> </p> <p> </div> <br /> <p> </p> </div> </div> <!-- end #primaryContent --> </div> </script> </body> </html>
Last edited by peter_budo : Jun 4th, 2008 at 2:42 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Jun 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Where you have this <?php echo $me;?> I have the actual php file name listed there. Might want to try that
[quote=dbowe1;619921]Hello. I have a form page that has been created with the fields: Name, Email, Phone (day), Phone (Eve), Address, and Comments. The form will need to be sent to an email address upon clicking the submit button. I have read some previous posts and tried using some of the code suggested with the code below being one that worked for another user. When I go to the testing server to test the form I get an htdocs/missing.htm page instead of the form being submitted or giving a form not submitted error message. Could there be a problem with the permissions of the file, or am I missing something with the code? Thanks.
Here is the code:
<!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">
<head>
<title> - City Hall Directory</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form id="form1" method="post" action="<?php echo $me;?>">
[quote=dbowe1;619921]Hello. I have a form page that has been created with the fields: Name, Email, Phone (day), Phone (Eve), Address, and Comments. The form will need to be sent to an email address upon clicking the submit button. I have read some previous posts and tried using some of the code suggested with the code below being one that worked for another user. When I go to the testing server to test the form I get an htdocs/missing.htm page instead of the form being submitted or giving a form not submitted error message. Could there be a problem with the permissions of the file, or am I missing something with the code? Thanks.
Here is the code:
<!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">
<head>
<title> - City Hall Directory</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form id="form1" method="post" action="<?php echo $me;?>">
Hi dbow1,
Create the following php document and save it as mail.php:
Then place it in the same folder as your contact us page (contact_us.html)
To make things a little easier, I have created the form for you as well, place this code, where you would like the contact us form to appear:
And Finally, the CSS you need to style the form:
If you have any problems or need some help. Just ask.
Regards,
Create the following php document and save it as mail.php:
<?php
$visitor = $_POST['name'];
$visitormail = $_POST['email'];
$address = $_POST[['address'];
$tele = $_POST['tele'];
$teld = $_POST['teld'];
$notes = $_POST['comments'];
// form validation
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if ($visitor == "") {
echo 'You must provide your name to contact us. Please click the back, and try again';
$formgood = false;
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
if ($comments == "") {
echo 'You must provide comments in order to submit this form. Please click back, and try again.';
}
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $notes;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Message: $notes \n
From: $visitor ($visitormail)\n
Address: $address \n
Telephone (Day): $teld \n
Telephone (Evening): $tel \n
";
$from = "From: $visitormail\r\n";
// Change the email address to the one you use.
mail("you@email.com", $subject, $message, $from);
?>
<!-- Below is the confirmation message the user will see -->
<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />
Telephone Numbers: <?php echo $teld ?> ( <?php echo $tele ?> )
<br />
Address: <?php echo $address ?>
<br />
Message: <?php echo $notes ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>
<br /><br />
<a href="index.html"> Home </a></p>Then place it in the same folder as your contact us page (contact_us.html)
To make things a little easier, I have created the form for you as well, place this code, where you would like the contact us form to appear:
<div id="container"> <form method="post" action="mail.php"> <div id="row"> <div id="col"> Name: </div> <div id="col"> <input name="name" type="text" id="name" /> </div> </div> <div id="row"> <div id="col"> Email: </div> <div id="col"> <input name="email" type="text" id="email" /> </div> </div> <div id="row"> <div id="col"> Phone (day): </div> <div id="col"> <input name="teld" type="text" id="tel_day" /> </div> </div> <div id="row"> <div id="col"> Phone (evening): </div> <div id="col"> <input name="tele" type="text" id="tel_evening" /> </div> </div> <div id="row"> <div id="col"> Address: </div> <div id="col"> <input name="address" type="text" id="address" /> </div></div> <div id="row"> <div id="col"> Comments: </div> <div id="col"><textarea name="comments" cols="50" rows="10"></textarea></div> </div> <div id="row"><input name="send" type="submit" id="send" value="Send" /> <input name="clear" type="reset" id="clear" value="Clear" /> </div> </form> </div>
And Finally, the CSS you need to style the form:
#container {
width: 768px;
height: 400px;
}
#row {
width:100%;
margin:2px;
height:auto;
float:left;
}
#col{
width:25%;
margin:2px;
float:left;
height:auto;
}If you have any problems or need some help. Just ask.
Regards,
Last edited by macneato : Jun 4th, 2008 at 3:02 am. Reason: Typos
If this reply solved your problem, please add to my reputation and don't forget to mark this thread as solved.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Site Layout and Usability Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
advertisment advice botnet browser business cell chain mail daniweb email email misuse encryption eu eudora expose firefox gmail google imap india malware microsoft mobile mozilla naked news onecare open source opinion outlook penelope phishing phones professional research scam security spam spammers spamming stocks technology thunderbird uk.government video virus visa web webmail
- AJAX Send Email Form with prototype and PHP (JavaScript / DHTML / AJAX)
- Need Help Making a Form send to an email using PHP (PHP)
- cdoMessage.To=Request.Form("email") (ASP)
- Email from Webpage (PHP)
- Problems in Dynaform (Form Mail) URGENT HELP (PHP)
- Please help with email form script (PHP)
- php mail form - need to redirect to new page (PHP)
- Form not sending email (PHP)
- Sending form email (PHP)
- Error getting forms to send information (PHP)
Other Threads in the Site Layout and Usability Forum
- Previous Thread: Help with remaking existing site into CSS-layout struggle
- Next Thread: Dreamweaver Layout Problem


Linear Mode