User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 428,569 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,653 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 ColdFusion advertiser: Programming Forums
Views: 44657 | Replies: 13
Reply
Join Date: Feb 2007
Posts: 4
Reputation: TrailBlazer is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
TrailBlazer TrailBlazer is offline Offline
Newbie Poster

Re: Dreamweaver email forms

  #11  
Feb 5th, 2007
Originally Posted by bkendall View Post
your form page will be just like any other page except that it will have form tags

<form name="form1" id="form1" method="post" action="">
  Field Name: 
  <input name="field name" type="text" id="field name" />
</form>

the action=''''> is where you would need to use a langauge such as php which might look like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
	"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Contact Form</title>
<meta http-equiv="Content-Type" 
   content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $me = $_SERVER['PHP_SELF'];
?>
   <form name="form1" method="post"
         action="<?php echo $me;?>">
      <table border="0" cellspacing="0" cellpadding="2">
         <tr>
            <td>Name:</td>
            <td><input type="text" name="Name"></td>
         </tr>
         <tr>
            <td>Subject</td>
            <td><input type="text" name="Subject"></td>
         </tr>
         <tr>
            <td valign="top">Message:</td>
            <td><textarea name="MsgBody"></textarea></td>
         </tr>
         <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="Submit"
               value="Send"></td>
         </tr>
      </table>
   </form>
<?php
   } else {
      error_reporting(0);
      $recipient = 'me@myaddress.com';
      $subject = stripslashes($_POST['Subject']);
      $from = stripslashes($_POST['Name']);
      $msg = "Message from: $from\n\n".stripslashes($_POST['MsgBody']);
      if (mail($recipient, $subject, $msg))
         echo nl2br("<b>Message Sent:</b>
         To: $recipient
         Subject: $subject
         Message:
         $msg");
      else
         echo "Message failed to send";
}
?>
</body>
</html>

You will need to check if you have access to a php server if not there are other methods that you can use. If all else fails you can send it via javascript, which is a dirty way to do it but will work.



This was the best help. In a matter of a few minutes I had this email form up and running inside a table on my site. Thanks!

I do have a ? though. Is it possible to somehow encrypt or 'hide' the email address that receives the form? (So it does not get crawled and spammed)


Thanks again!
Reply With Quote  
Join Date: Feb 2007
Posts: 6
Reputation: Ashjenius is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Ashjenius's Avatar
Ashjenius Ashjenius is offline Offline
Newbie Poster

Re: Dreamweaver email forms

  #12  
Feb 17th, 2007
Originally Posted by bkendall View Post
your form page will be just like any other page except that it will have form tags

 
<form name="form1" id="form1" method="post" action="">
  Field Name: 
  <input name="field name" type="text" id="field name" />
</form>
 

the action=''''> is where you would need to use a langauge such as php which might look like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Contact Form</title>
<meta http-equiv="Content-Type" 
   content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $me = $_SERVER['PHP_SELF'];
?>
   <form name="form1" method="post"
         action="<?php echo $me;?>">
      <table border="0" cellspacing="0" cellpadding="2">
         <tr>
            <td>Name:</td>
            <td><input type="text" name="Name"></td>
         </tr>
         <tr>
            <td>Subject</td>
            <td><input type="text" name="Subject"></td>
         </tr>
         <tr>
            <td valign="top">Message:</td>
            <td><textarea name="MsgBody"></textarea></td>
         </tr>
         <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="Submit"
               value="Send"></td>
         </tr>
      </table>
   </form>
<?php
   } else {
      error_reporting(0);
      $recipient = 'me@myaddress.com';
      $subject = stripslashes($_POST['Subject']);
      $from = stripslashes($_POST['Name']);
      $msg = "Message from: $from\n\n".stripslashes($_POST['MsgBody']);
      if (mail($recipient, $subject, $msg))
         echo nl2br("<b>Message Sent:</b>
         To: $recipient
         Subject: $subject
         Message:
         $msg");
      else
         echo "Message failed to send";
}
?>
</body>
</html>

You will need to check if you have access to a php server if not there are other methods that you can use. If all else fails you can send it via javascript, which is a dirty way to do it but will work.


How would i go about adjusting the end section of script if i have put in an email address text box in the form.

Regards
Ashjenius
Reply With Quote  
Join Date: Feb 2007
Posts: 4
Reputation: TrailBlazer is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
TrailBlazer TrailBlazer is offline Offline
Newbie Poster

Re: Dreamweaver email forms

  #13  
Apr 18th, 2007
So this email form works perfectly that I quoted before a few posts up. I was wondering though how to make 1-2 fields a required fill in subject line. Nothing fancy like checking to make sure it's a valid email address, but just so they have to type something in the Name box the Email box.
If anyone would be willing to help out I'd be greatly appreciated. Here is the php script I'm using now but I have no idea who emails me since the email field is cgi-mailer@perfora.net.

Code works now fine, but I just want to add a *required Name field and *required email address field:

<html>
<head>
<title>Sandy Sanders Designs</title>
<meta name="keywords" content="Sandy Sanders,Sandy,graphic design,photography,osx,OSX,macintosh,mac,Gainesville,Florida,Maintosh,Mac">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="file://tabletext.css" rel="stylesheet" type="text/css"><link href="../tabletext.css" rel="stylesheet" type="text/css">
<script type="text/JavaScript">
<!--



function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
<style type="text/css">
<!--
.style2 {font-size: 10px}
#Layer1 {
position:absolute;
left:69px;
top:241px;
width:111px;
height:275px;
z-index:1;
}
body {
background-image: url(../images/background.jpg);
background-repeat: no-repeat;
}
.style3 {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
}
.style4 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
.style5 {font-family: Verdana, Arial, Helvetica, sans-serif}
-->
</style>
<script type="text/javascript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="preloadImages();MM_preloadImages('../images/homeover.gif','../images/photoover.gif','../images/logosover.gif','../images/webdesignover.gif','../images/linksover.gif','../images/filesover.gif')">
<p>
<!-- ImageReady Slices (navbar.psd) -->
</p>
<p>&nbsp;</p>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"><img src="../images/expandboxtop.gif" width="800" height="13"></td>
</tr>
<tr>
<td><table width="800" height="637" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="800" height="141" align="center" valign="top" bgcolor="#FFFFFF"><br>
<a href="../index.html"><img src="../images/sslogonew.gif" width="387" height="123" border="0"></a></td>
</tr>
<tr>
<td height="20" colspan="2" align="center" valign="top" bgcolor="#FFFFFF"><a href="../index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','../images/homeover.gif',1)"></a><a href="photography.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','../images/photoover.gif',1)"></a><a href="logos.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','../images/logosover.gif',1)"></a><a href="webdesign.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','../images/webdesignover.gif',1)"></a><a href="links.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image11','','../images/linksover.gif',1)"></a><a href="http://sandysandersdesigns.com/files/temp" target="_blank" onMouseOver="MM_swapImage('Image12','','../images/filesover.gif',1)" onMouseOut="MM_swapImgRestore()"></a><a href="../index.html"><img src="../images/newnavbar/nav1.jpg" width="102" height="61" border="0"></a><a href="photography.html"><img src="../images/newnavbar/nav2.jpg" width="99" height="61" border="0"></a><a href="pages/logos.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','images/NavBar/3over.jpg',1)"></a><a href="logos.html"><img src="../images/newnavbar/nav3.jpg" width="89" height="61" border="0"></a><a href="webdesign.html"><img src="../images/newnavbar/nav4.jpg" width="53" height="61" border="0"></a><a href="links.html"><img src="../images/newnavbar/nav5.jpg" width="53" height="61" border="0"></a><a href="http://sandysandersdesigns.com/files/temp" target="_blank"><img src="../images/newnavbar/nav6.jpg" width="51" height="61" border="0"></a><a href="contact2.php"><img src="../images/newnavbar/nav7.jpg" width="114" height="61" border="0"></a><a href="contact.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image15','','../images/contactover.gif',1)"></a></td>
</tr>
<tr>
<td height="312" align="left" valign="top" bgcolor="#FFFFFF"><table width="131" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="70" height="49">&nbsp;</td>
<td width="61">&nbsp;</td>
</tr>
<tr>
<td height="58" align="center" valign="top"><a href="../fliesold.html"></a></td>
<td align="center" valign="top"><a href="orangelake1.html"></a></td>
</tr>
<tr>
<td height="19" align="center" valign="top" class="style2"><img src="../images/spacerbotmarg.gif" width="10" height="16"></td>
<td align="center" valign="top">&nbsp;</td>
</tr>
<tr>
<td height="58" align="center" valign="top"><a href="../fliesold.html"></a></td>
<td align="center" valign="top"><a href="orangelakeold.html"></a></td>
</tr>
<tr>
<td height="19" align="center" valign="top"><img src="../images/spacerbotmarg.gif" width="10" height="16"></td>
<td align="center" valign="top"></td>
</tr>
<tr>
<td height="57" align="center" valign="top"><a href="../fliesold.html"></a></td>
<td align="center" valign="top"><a href="orangelakeold.html"></a></td>
</tr>
<tr>
<td height="19" align="center" valign="top"><img src="../images/spacerbotmarg.gif" width="10" height="16"></td>
<td align="center" valign="top">&nbsp;</td>
</tr>
<tr>
<td height="59" align="center" valign="top"><a href="../fliesold.html"></a></td>
<td align="center" valign="top"><a href="orangelakeold.html"></a></td>
</tr>
<tr>
<td height="19" align="center" valign="top"><img src="../images/spacerbotmarg.gif" width="10" height="16"></td>
<td align="center" valign="top">&nbsp;</td>
</tr>
<tr>
<td height="59" align="center" valign="top"><a href="../fliesold.html"></a></td>
<td align="center" valign="top"><a href="orangelakeold.html"></a></td>
</tr>
<tr>
<td height="59" align="center" valign="top">&nbsp;</td>
<td align="center" valign="top">&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
<table width="275" height="35" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="298" height="35" align="left" valign="top"><img src="../images/buttons/contactinfo.gif" width="275" height="46"><br>
<a href="http://www.aboutus.org/SandysAndersDesigns.com" target="_blank" class="style4">about us.org</a> <br>
<br>
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = $_SERVER['PHP_SELF'];
?>
<form name="form1" method="post"
action="<?php echo $me;?>">
<table border="0" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td><span class="style5">Name:</span></td>
<td><input type="text" name="Name"></td>
</tr>
<tr>
<td class="style5">Subject:</td>
<td><input type="text" name="Subject"></td>
</tr>
<tr>

<td valign="top"><span class="style5">Message:</span></td>
<td><textarea name="MsgBody" cols="45" rows="17"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit"
value="Send"></td>
</tr>
</table>
</form>
<?php
} else {
error_reporting(0);
$recipient = 'fake@fakeemail.com';
$subject = stripslashes($_POST['Subject']);
$from = stripslashes($_POST['Name']);
$msg = "Message from: $from\n\n".stripslashes($_POST['MsgBody']);
if (mail($recipient, $subject, $msg))
echo nl2br("<b>Message Sent:</b>
To: $recipient
Subject: $subject
Message:
$msg");
else
echo "Message failed to send";
}
?>
</td>
</tr>
</table>
<p class="style4">&nbsp;</p></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" valign="top"><img src="../images/expandboxfly7bott.gif" width="800" height="13"></td>
</tr>
</table>
<div align="center">
<span class="style3">Copyright &copy; 2006 Sandy Sanders</span>
</div>
<p align="center"><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-754277-2";
urchinTracker();
</script>
</p>
</body>
</html>

****The only thing I changed or posting this code on the web was my email address.
$recipient = 'fake@fakeemail.com'; hehehe

Again any help would be greatly appreciated!

p.s. I really hope I'm not spamming, but maybe in hopes that if I get a answer so will others

Cheers,
Reply With Quote  
Join Date: Aug 2008
Posts: 1
Reputation: vincearcuri is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
vincearcuri vincearcuri is offline Offline
Newbie Poster

Re: Dreamweaver email forms

  #14  
Aug 5th, 2008
Great stuff, thanks!

- Vince
<URL SNIPPED>
Last edited by peter_budo : Aug 5th, 2008 at 12:16 pm. Reason: Please use control panel to edit your signature. No fake signatures in posts!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ColdFusion Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the ColdFusion Forum

All times are GMT -4. The time now is 11:14 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC