Help - Search - Members - Calendar
Full Version: Email Form
Zymic Webmaster Forums > Web Design & Development > General Web Design Discussion
wozzym
Hello again,

I am in the process of learning php and decided to try some out. The following is a code for an email form. This will let users on your site email you while on your site with feedback/ideas e.t.c. So here we go!

Please create a file called mail_form.php. If you give the file a different name, please change the file name in the code wink.gif
CODE
<html>
<body>

<form action="MAILTO:Youremail@email.com" method="post">
<table border="0" bgcolor="grey" cellspacing="6">
<tr><td>Name</td><td><input type="text" size="30" name="name" value="name">
</td>
</tr>
<tr><td>Email address</td><td><input type="text" size="30" name="email" value="Email">
</td>
</tr>
<tr><td valign="top">Messsage</td><td><textarea name="comments" rows="10" cols="30">
</textarea>
</td>
</tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Send">
</table>
</form>
</body>
</html>


OR

CODE
<html>
<body>
<form>
<table border="0" bgcolor="F5F5F5" cellspacing="6">
<tr><td>Name:</td><td><input type="text" size="30" name="name" value="Your Name">
</td>
</tr>
<tr><td>Email Address:</td><td><input type="text" size="30" name="email" value="Your Email">
</td>
</tr>
<tr><td valign="top">Messsage:</td><td><textarea name="message" value="Type your message here!" rows="10" cols="30">
</textarea>
</td>
</tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Send">
</table>
</form>
<?php
{
  $name = $_REQUEST['name'];
  $email = $_REQUEST['email'];
  $message = $_REQUEST['message'];
  mail( "youremail@email.com", "Subject: $message",
  $message, "From: $email" );
  echo "Thanks, your message has been sent.";
  }
?>

</body>
</html>

And there you go! You now have a email form in your website smile.gif

Preview
Jetteh22
Neat

One thing you could look into though, if your actually planning on having people email you from it is...

The thing that I do, actually, is I create a feedback form / contact us form... From there, though, the things they submit do not get sent to my email, it gets sorted into a mysql database..

I can then go through to my backdoor system I created and see each and every message that was submitted put into divs/tables/whatever that I made so it is sorted how i want, i can see it how i want, and i can see them all on ONE page...

And then, from there, instead of "emailing them back" I usually just post their question/comment and my response on the same page as the contact page, so others can read it too tongue.gif


I like that idea more lol. May not offer as much "user-interaction" but who says I want to be bothered with the same questions over and over again? biggrin.gif
Alex
Needs validation and sanitisation (for header injection, and just so you don't get rubbish)

It should also have some facility to prevent abuse, so, say, only allowing one email per IP address per minute. You can use a simple flatfile for this (since it should never get over a few lines at the absolute maximum).

Your HTML isn't valid, and is somewhat messy.

For large chunks of HTML output you might find it neater to break out of PHP (?>), have your HTML and then go in again. As opposed to a huge interpolated echo statement.

The comments don't really add value to the code, the if statement says plainly what it's doing, no need to say it again.

Keep working on it, but I would recommend making throwaway systems for yourself rather than having others use them.
wozzym
thanks for your responses. I am still learning php so the feedback is really appreciated smile.gif
wozzym
new version. first post updated smile.gif
Luke Spragg
Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The mail() command is not allowed.
wozzym
ya this will only work if you are not using zymic. zymic has restricted the use of mail on your site...
Luke Spragg
QUOTE(wozzym @ Apr 1 2008, 08:56 PM) *
ya this will only work if you are not using zymic. zymic has restricted the use of mail on your site...

I am not trying to use it on my site tongue.gif I was just looking at yours.
wozzym
QUOTE(Creactive Online @ Mar 30 2008, 12:36 PM) *
Neat

One thing you could look into though, if your actually planning on having people email you from it is...

The thing that I do, actually, is I create a feedback form / contact us form... From there, though, the things they submit do not get sent to my email, it gets sorted into a mysql database..

I can then go through to my backdoor system I created and see each and every message that was submitted put into divs/tables/whatever that I made so it is sorted how i want, i can see it how i want, and i can see them all on ONE page...

And then, from there, instead of "emailing them back" I usually just post their question/comment and my response on the same page as the contact page, so others can read it too tongue.gif
I like that idea more lol. May not offer as much "user-interaction" but who says I want to be bothered with the same questions over and over again? biggrin.gif


I might be able to do this with a pm integration? or how else?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.