Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 8, 2008, 01:29 PM   #1
MacFan782040
macrumors 6502a
 
MacFan782040's Avatar
 
Join Date: Dec 2003
Location: Scranton, PA
Text Box that will send an email

Hey everyone,

What I am trying to do is create a form on my website that people can type stuff in a text box and it will email it to my address. I've done it before, but I think it was on my Geocities site and it was already setup for me.

I know there is a javascript out there that will do it, but all the ones I have googled don't seem to work. Do I need something special on my server? If anyone can provide me with a script that would be great.

Thanks a lot!
MacFan782040 is offline   0 Reply With Quote
Old Sep 8, 2008, 01:37 PM   #2
TEG
macrumors 603
 
TEG's Avatar
 
Join Date: Jan 2002
Location: Langley, Washington
Send a message via ICQ to TEG Send a message via AIM to TEG Send a message via MSN to TEG Send a message via Yahoo to TEG Send a message via Skype™ to TEG
The one here: http://www.web-source.net/html_email_form.htm requires the user to actually have an e-mail client. Most others I see either require server-side software or a lot of PHP code.

TEG
__________________
Apple and Dell are the only ones in this industry making money. They make it by being Wal-Mart. We make it by innovation, - Steve Jobs
The Tegian Zone-Glass Onion Radio
TEG is offline   0 Reply With Quote
Old Sep 8, 2008, 02:10 PM   #3
jdl8422
macrumors 6502
 
Join Date: Jul 2006
Location: Louisiana
Free PHP Form Creator
__________________
jdl8422 is offline   0 Reply With Quote
Old Sep 8, 2008, 02:46 PM   #4
bootedbear
macrumors 6502
 
Join Date: Sep 2004
Location: Austin, TX
HTML and JavaScript have no ability to send mail. The best that they can do, as TEG's link shows, is to cause a window in the local email client to open in order to use it to send the message.

If you want to send the message directly from the page, there must be a server-side component to handle it.

There are tons of PHP examples out there, and JavaMail is pretty easy to use if your backend is Java powered.
bootedbear is offline   0 Reply With Quote
Old Sep 8, 2008, 04:10 PM   #5
ChrisA
macrumors G3
 
Join Date: Jan 2006
Location: Redondo Beach, California
It's easy. Your form simply sends the test back to the server. A script on the server then stuffs the text into a system command (such as "sendmail") then the script sends the command to be run by using a "system" or "exec" command.
ChrisA is offline   0 Reply With Quote
Old Sep 8, 2008, 08:14 PM   #6
MacFan782040
Thread Starter
macrumors 6502a
 
MacFan782040's Avatar
 
Join Date: Dec 2003
Location: Scranton, PA
Thanks a lot everyone. I knew there had to be a server-side to it. I got one to work that opens up an email client, but a lot of people don't have theirs set up and stuff like that.

I use Go Daddy for my site, so I'll check with them to see if they have anything available to use.

*Edit*- I used the link provided by jdl8422 and it worked great. Thanks

Last edited by MacFan782040; Sep 8, 2008 at 08:38 PM.
MacFan782040 is offline   0 Reply With Quote
Old Sep 8, 2008, 08:38 PM   #7
angelwatt
Demi-God (Moderator emeritus)
 
angelwatt's Avatar
 
Join Date: Aug 2005
Location: Ohio
Quote:
Originally Posted by MacFan782040 View Post
Thanks a lot everyone. I knew there had to be a server-side to it. I got one to work that opens up an email client, but a lot of people don't have theirs set up and stuff like that.

I use Go Daddy for my site, so I'll check with them to see if they have anything available to use.
This page may be of help, it's from GoDaddy's site for their Form-Mailer.
angelwatt is offline   0 Reply With Quote
Old Sep 10, 2008, 11:50 PM   #8
montanachad
Banned
 
Join Date: Jul 2008
Location: Helena, Montana and Lacey, Washington
Send a message via Yahoo to montanachad
I used these php files for my website: http://www.ibdhost.com/contact/
montanachad is offline   0 Reply With Quote
Old Sep 11, 2008, 09:14 AM   #9
MCRunning
macrumors 6502
 
Join Date: Sep 2008
Here is something quick I just wrote up:

contact.php
PHP Code:
  <table width="100%" cellpadding="1" cellspacing="1">
  <
tr>
  <
td width="600" valign="top">
  <
h3>Contact WebsiteName </h3>
  <
p>If you have any commentsquestions, or concernsplease use the form below.</p>
  <
form method="post" action="sendmail.php">
  <
table width="500">
  <
tr>
  <
td valign="top">Name:</td><td><input type="text" size="30" name="name" /></td>
  </
tr>
  <
tr>
  <
td valign="top">E-mail:</td><td><input type="text" size="30" name="email" /></td>
  </
tr>
  <
tr>
  <
td valign="top">2:</td><td><input type="text" size="30" name="verify" />(like youwe don't like spam)</td>
  </tr>
  <tr>
  <td valign="top">Comments:</td>
  <td><textarea cols="50" rows="8" name="comments"></textarea></td>
  </tr>
  <tr>
  <td></td>
  <td><input type="submit" value="Submit" /></td>
  </tr>
  </table>
  </form>
</td> 

sendmail.php
PHP Code:
<?
//send us your mail
if($verify == 4)
{
mail('email@website.com','subject',$comments,'From: '.$name.' <'.$email.'>');
header'Location: website' );
}
else
{
 
header'Location: website' );
}
?>
Messy, but should get the job done.

MC
MCRunning is offline   0 Reply With Quote
Old Sep 11, 2008, 09:58 AM   #10
angelwatt
Demi-God (Moderator emeritus)
 
angelwatt's Avatar
 
Join Date: Aug 2005
Location: Ohio
Quote:
Originally Posted by MCRunning View Post
Here is something quick I just wrote up:
Table layouts. Really? The code also isn't valid or semantically correct. I know you're trying to give a short example, but the code does next to no validation. If you were to actually use that code you would have your inbox spammed big time and likely would become someones spambot and you'd be legally responsible. That PHP code should not be used as is, it could make for a starting point though.

Until a developer is comfortable with data validation and the like, I recommend sticking with scripts that have been developed well and take these extra things into consideration for you so you don't get yourself into spam hell.

Last edited by angelwatt; Sep 11, 2008 at 10:28 AM.
angelwatt is offline   0 Reply With Quote
Old Sep 11, 2008, 10:18 AM   #11
MacFan782040
Thread Starter
macrumors 6502a
 
MacFan782040's Avatar
 
Join Date: Dec 2003
Location: Scranton, PA
All of you are awesome. Thanks for the help.

I have 1 more for ya...

Basically I run my organization's website. We are required to do library hours, and usually we log them in a binder at the library, but we wanted to see if we could do it instead on our website.

Is there some kind of database script that will allow about 50 people or so to choose their name, and then add hours, and it will update a table with everyone's names and hours?

Thanks again!
MacFan782040 is offline   0 Reply With Quote
Old Sep 11, 2008, 10:32 AM   #12
angelwatt
Demi-God (Moderator emeritus)
 
angelwatt's Avatar
 
Join Date: Aug 2005
Location: Ohio
Quote:
Originally Posted by MacFan782040 View Post
Is there some kind of database script that will allow about 50 people or so to choose their name, and then add hours, and it will update a table with everyone's names and hours?
You'll want something like this Time Management script. I've come across various scripts that do time management and there are good free ones, but I have not used any personally so won't make any specific recommendations. I'll simply say Google search.
angelwatt is offline   0 Reply With Quote
Old Sep 11, 2008, 10:38 AM   #13
MCRunning
macrumors 6502
 
Join Date: Sep 2008
Quote:
Originally Posted by angelwatt View Post
Table layouts. Really? The code also isn't valid or semantically correct. I know you're trying to give a short example, but the code does next to no validation. If you were to actually use that code you would have your inbox spammed big time and likely would become someones spambot and you'd be legally responsible. That PHP code should not be used as is, it could make for a starting point though.

Until a developer is comfortable with data validation and the like, I recommend sticking with scripts that have been developed well and take these extra things into consideration for you so you don't get yourself into spam hell.
Better? He can modify the code to his own needs. All he asked for was a text box that can send whatever to his email and that is what I provided.

PHP Code:
<?php

// Check for form submission:
if (isset($_POST['submitted'])) {

    
// Minimal form validation:
    
if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comments']) ) {
    
        
// Create the body:
        
$body "Name: {$_POST['name']}\n\nComments: {$_POST['comments']}";
        
        
// Make it no longer than 100 characters long:
        
$body wordwrap($body100);
    
        
// Send the email:
        
mail('your_email@example.com''Contact Form Submission'$body"From: {$_POST['email']}");
        
        
// Print a message:
        
echo '<p><em>Thank you for contacting me. I will reply some day.</em></p>';
        
        
// Clear $_POST (so that the form's not sticky):
        
$_POST = array();
    
    } else {
        echo 
'<p style="font-weight: bold; color: #C00">Please fill out the form completely.</p>';
    }
    
// End of main isset() IF.

// Create the HTML form:
?>
<p>Please fill out this form to contact me.</p>
<form action="email.php" method="post">
    <p>Name: <input type="text" name="name" size="30" maxlength="60" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></p>
    <p>Email Address: <input type="text" name="email" size="30" maxlength="80" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p>
    <p>Comments: <textarea name="comments" rows="5" cols="30"><?php if (isset($_POST['comments'])) echo $_POST['comments']; ?></textarea></p>
    <p><input type="submit" name="submit" value="Send!" /></p>
    <input type="hidden" name="submitted" value="TRUE" />
</form>
</body>
</html>
MC
MCRunning is offline   0 Reply With Quote
Old Sep 11, 2008, 03:19 PM   #14
angelwatt
Demi-God (Moderator emeritus)
 
angelwatt's Avatar
 
Join Date: Aug 2005
Location: Ohio
Quote:
Originally Posted by MCRunning View Post
Better? He can modify the code to his own needs. All he asked for was a text box that can send whatever to his email and that is what I provided.
If the OP is asking about sending emails from a page, do you really believe he'll know about PHP validation? The new HTML you provided looks a lot better without the tables. The minimal validation you're doing is certainly a start, but could still easily be turned into a spambot. I'm not saying you need to post code that is immensely validated or anything. I just like it to be clear to the OP that it's a minimal setup and that leaving the code as is will very likely leave them open to having their site turned into a spambot. This is also why I advise people to use pre-built scripts unless they're developers themselves and understand these potential problems. Essentially just making sure the OP knows there is a disclaimer with the code.

This wasn't attack on you MCRunning, I just want to make sure the OP doesn't think he can copy and paste the code you provide as is without further consideration, and to also explain why he shouldn't. Your post simply opened up that opportunity so don't take what I've said personally because it's not meant as such.

For those interested in using PHP for form validation like you would do for a contact form you can find some good reading at PHP Security Consortium to get you thinking about security.

Others readings:
angelwatt is offline   0 Reply With Quote
Old Sep 11, 2008, 04:06 PM   #15
MCRunning
macrumors 6502
 
Join Date: Sep 2008
I totally see where you are coming from angel, but at the same time it's like when you hire someone to do your work for you. If you don't tell them exactly what you want, you will get exactly what you paid for.

Say he hired a programmer to do this job for him and asked for a text box that when a user submitted information it emailed him whatever was in the text box. The programmer will give him exactly that, then later he realizes he is getting spammed and needs validation. He will go back to the programmer and say why didn't you include validation?! And of course the programmer will say "you didn't ask for validation".

Hopefully a lesson was learned from this

MC
MCRunning is offline   0 Reply With Quote
Old Sep 11, 2008, 04:32 PM   #16
angelwatt
Demi-God (Moderator emeritus)
 
angelwatt's Avatar
 
Join Date: Aug 2005
Location: Ohio
Quote:
Originally Posted by MCRunning View Post
Hopefully a lesson was learned from this
Yea, get a better programmer that keeps the customer's lack of knowledge in mind

Kidding aside though, customers will never be able to tell a programmer exactly what they want/need. If they knew that level of detail they'd likely be able to do it them self. I work in an area where even amongst professionals who work together on a regular basis, but with differing backgrounds, have a lot of trouble talking about certain things because they come from different areas and perspectives.

A good programmer will know what follow up questions to do with a customer (through experience) and what things to provide that are not asked for, but are needed. I mean when you want an oil change for your car you don't tell the mechanic that the old oil removed as well. He'd likely upset at you telling him his job and for making stupid statements.

OK, I'm done talking off topic. Sorry to OP for getting so far off from topic. Let us know if you need anything further.
angelwatt is offline   0 Reply With Quote
Old Sep 11, 2008, 05:45 PM   #17
MCRunning
macrumors 6502
 
Join Date: Sep 2008
PHP Code:
<?php
// Check for form submission:
if (isset($_POST['submitted'])) {
    function 
spam_scrubber($value) {
        
        
$very_bad = array('to:''cc:''bcc:''content-type:''mime-version:''multipart-mixed:''content-transfer-encoding:');
        
        foreach (
$very_bad as $v) {
            if (
stripos($value$v) !== false) return '';
        }
        
        
// Replace any newline characters with spaces:
        
$value str_replace(array( "\r""\n""%0a""%0d"), ' '$value);
        
        
// Return the value:
        
return trim($value);
    
    } 
// End of spam_scrubber() function.
    
    // Clean the form data:
    
$scrubbed array_map('spam_scrubber'$_POST);

    
// Minimal form validation:
    
if (!empty($scrubbed['name']) && !empty($scrubbed['email']) && !empty($scrubbed['comments']) ) {
    
        
// Create the body:
        
$body "Name: {$scrubbed['name']}\n\nComments: {$scrubbed['comments']}";
        
$body wordwrap($body100);
    
        
// Send the email:
        
mail('your_email@example.com''Contact Form Submission'$body"From: {$scrubbed['email']}");
        
        
// Print a message:
        
echo '<p><em>Thank you for contacting me. I will reply some day.</em></p>';
        
        
// Clear $_POST (so that the form's not sticky):
        
$_POST = array();
    
    } else {
        echo 
'<p style="font-weight: bold; color: #C00">Please fill out the form completely.</p>';
    }
    
// End of main isset() IF.
?>
<p>Please fill out this form to contact me.</p>
<form action="email.php" method="post">
    <p>Name: <input type="text" name="name" size="30" maxlength="60" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></p>
    <p>Email Address: <input type="text" name="email" size="30" maxlength="80" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p>
    <p>Comments: <textarea name="comments" rows="5" cols="30"><?php if (isset($_POST['comments'])) echo $_POST['comments']; ?></textarea></p>
    <p><input type="submit" name="submit" value="Send!" /></p>
    <input type="hidden" name="submitted" value="TRUE" />
</form>
</body>
</html>
More validation yay

MC
MCRunning is offline   0 Reply With Quote
Old Sep 12, 2008, 12:06 AM   #18
MacFan782040
Thread Starter
macrumors 6502a
 
MacFan782040's Avatar
 
Join Date: Dec 2003
Location: Scranton, PA
A huge thanks to all of you! I downloaded the Time Management thing from angelwatt but I don't really have a clue how to customize it.. I'm more familiar with HTML.

Last edited by MacFan782040; Sep 12, 2008 at 12:11 AM.
MacFan782040 is offline   0 Reply With Quote

Reply
MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Need an Aapp that will send SMS once connected MikeonTV iPhone and iPod touch Apps 3 Apr 13, 2011 02:54 PM
OS X app that will send text messages? theNEOone Mac Applications and Mac App Store 5 Mar 7, 2009 05:37 PM
Popup box when sending an email mbutler MacBook Pro 1 May 2, 2007 06:49 PM
Popup box when sending an email mbutler MacBook Pro 1 Apr 26, 2007 01:21 PM
Need app that will send me my current WAN IP via email G4Grover Mac Applications and Mac App Store 6 Oct 20, 2004 10:01 PM


All times are GMT -5. The time now is 02:32 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC