Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Bidding Directory   High Bandwidth Dedicated Servers   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 07-31-2006, 03:52 AM   #1 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
Question PHP: Email form

Hi guys i'm a total n00b at coding php I only know the basics i'm still learning.
Basicaly what i need is a form:

Name:
sing line text entry box
Email Address:
Single line text entry box

Then i want that form to be sent to my email via sendmail.php
but on the email sent to me i want the name of the person who sent the mail and alo their email in on sent by section so then my autoresponder can send them an email back.

This is simple know but for me its a learning process.

Thanks for any input

.~Optix~.
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 07-31-2006, 04:50 AM   #2 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
I was wandering could a mailing list software do this? but that would mean my computer be connected to the internet all the time?
also after the submit i need the page redirected to a thank you page

.~Optix~.
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 06:27 AM   #3 (permalink)
Inactive
 
ali_420's Avatar
 
Join Date: 06-16-06
Posts: 268
iTrader: 0 / 0%
Latest Blog:
None

ali_420 is on the right pathali_420 is on the right pathali_420 is on the right path
Hey optix,
I think the best option for you would be to look around at some autoresponder/mailing list programs like you said (I found this one: http://www.aweber.com). You wouldn't need to be connected all the time. All you would need is to sign up with them, and they'll give you some code that you could put in your website and it would show that form.

They would also let you specify what page people are taken to after they put in their email address and click the button.
The downside is that they aren't free. You'll have to spend a couple of bucks at it to make it work.

By the way do you have an autoresponder setup on your website? If you do, and you don't want to buy a mailing list program (which you should buy if you can) then I can give you a quick script which sends an email after they submit their email address and takes them to a page that you specify.
ali_420 is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 06:36 AM   #4 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
Salaam.
Yes Ali that is exactly what I need. could you please code me the script

Many thanks

Wasalaam.
.~Optix~.
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 07:48 AM   #5 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
Ali seems to have vanished:S Is there any one else who can do the job?

.~Optix~.
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 09:38 AM   #6 (permalink)
Junior Member
 
Join Date: 05-16-06
Location: UK
Posts: 6
iTrader: 0 / 0%
Latest Blog:
None

ApricotWeb is liked by many
This is the script I'm using on a few of my websites. At the moment, like any form on a website, I'm having problems with people spamming them. One technique I have used is to not let them use an email address containing "@mydomain.com". This has cut out about 95% of the spam. I was wondering what other methods people are using?
PHP Code:
if ( $_POST['send'] )
{
  
$Name stripslashes(trim($_POST['name']));
  
$Email trim($_POST['email']);
  
$Subject stripslashes(trim($_POST['subject']));
  
$Message stripslashes($_POST['message']);

  if ( !
$Message || str_word_count($Message) > 300 )
    
$E_Message=true;
                
  if ( !
$Email || !preg_match("/[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})/i"$Email) ) 
    
$E_Email true;

  if ( !
$E_Email && !$E_Message )
  {
    if ( !
$Subject 
      
$Subject 'Question';

    
$Sent mail('you@example.com'$Subject$Message"From: \"".$Name."\" <".$Email.">");

    if ( 
$Sent )
    {
      echo(
"<p class=\"warning\">Thank you, your message has been sent. We will be in contact with you shortly.</p>\n");
      unset(
$Name$Email$Subject$Message);
    }
  }
 } 
You can put this into sendmail.php or you can put it into the same page as the email form.

Your form should look like this.
HTML Code:
<form method="post" action="/sendmail.php"> <p> Name<br> <input name="name" type="text" size="45" value=""><br> Valid Email<br> <input name="email" type="text" size="45" value=""><br> Subject<br> <input name="subject" type="text" size="45" value=""><br> Message (Max 300 Words)<br> <textarea name="message" rows="12" cols="43"></textarea><br> <input type="submit" name="send" value="Send"> </p> </form>
This is the base for you, you can add error reporting if you like. You can use the variables $E_Email and $E_Message for this. It is also nice to propagate the form if there was an error so the user doesn't have to write it all again (obviously you can only do this if the form and the script is on the same page.)
ApricotWeb is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 09:46 AM   #7 (permalink)
Inactive
 
ali_420's Avatar
 
Join Date: 06-16-06
Posts: 268
iTrader: 0 / 0%
Latest Blog:
None

ali_420 is on the right pathali_420 is on the right pathali_420 is on the right path
Hey, sorry optix. I just saw your post and I was about to code you the script but saw that Appricot already did it. Well, if you need any help later on let me know
ali_420 is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 09:52 AM   #8 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
Warning: mail() expects at least 3 parameters, 2 given in /home/cpanel/optix/public_html/test.php on line 11


Hellpp

line 11 is

$Sent = mail('atif_Khan@hotmail.co.uk', "From: \"".$Name."\" <".$Email.">");

.~Optix~.
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 09:54 AM   #9 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
oh w8 it might be the extra quotation let see
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 09:57 AM   #10 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
ok basicaly i tired it edit the script so that the only two fileds are name and email:


the php

Code:
<? if ( $_POST['send'] ) { $Name = stripslashes(trim($_POST['name'])); $Email = trim($_POST['email']); { if ( !$Subject ) $Subject = 'Free SEO'; $Sent = mail('goawayspamer@spamland.com, "From: \"".$Name."\" <".$Email.">); if ( $Sent ) { echo("<p class=\"warning\">Thank you, your message has been sent. We will be in contact with you shortly.</p>\n"); unset($Name, $Email); } } } ?>
the html

Code:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form method="post"> <p> Name<br> <input name="name" type="text" size="45" value=""><br> Valid Email<br> <input name="email" type="text" size="45" value=""><br> <input type="submit" name="send" value="Send"> </p> </form> </body> </html>
after taking out the extra quotation the error i get know is
Parse error: syntax error, unexpected T_CLASS in /home/cpanel/optix/public_html/test.php on line 15
and i dont get an email

Last edited by Optix : 07-31-2006 at 10:08 AM.
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 10:02 AM   #11 (permalink)
Junior Member
 
Join Date: 05-16-06
Location: UK
Posts: 6
iTrader: 0 / 0%
Latest Blog:
None

ApricotWeb is liked by many
You need to have the Subject and Message there, you can leave it as an empty string if you want, but then you wont get there message just an empty email.

$Sent = mail("you@example.com", "", "", "From: \"".$Name."\" <".$Email.">");

PS. I would remove your email address from the above post if I was you. Otherwise you WILL start receiving loads of spam.
ApricotWeb is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 10:09 AM   #12 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
Thank for the heads up
Empty email is good because the email is going to be an autoresponder so no problem there.
I shall try your edit and get back to you

Thanks again

.~Optix~.
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 10:13 AM   #13 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
actuly to be safe i'll have the subject.
can i have it set to whatever i want it to be?

can you tell me which line to change to what please

.~optix~.

Last edited by Optix : 07-31-2006 at 10:42 AM.
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 10:39 AM   #14 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
BUMP*
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 12:27 PM   #15 (permalink)
Inactive
 
ali_420's Avatar
 
Join Date: 06-16-06
Posts: 268
iTrader: 0 / 0%
Latest Blog:
None

ali_420 is on the right pathali_420 is on the right pathali_420 is on the right path
Hiya optix,
change:
PHP Code:
$Sent mail('goawayspamer@spamland.com, "From: \"".$Name."\" <".$Email.">); 
to:
PHP Code:
$Sent mail('goawayspamer@spamland.com'"Subject here","Any message you want to put here","From: \"$Name\"<".$Email.">"); 
Try it and let me know how it goes.

Edit: There was a little typo in the code, if you tried it before try it again now.

Last edited by ali_420 : 07-31-2006 at 12:31 PM.
ali_420 is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 12:53 PM   #16 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
Hi Ali
Thanks for the response and it worked.
I know need a redirect to a thank you page.
Can you give me the code for that please

Thanks a bunch for your help!!

.~Optix~.
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-31-2006, 02:12 PM   #17 (permalink)
Inactive
 
ali_420's Avatar
 
Join Date: 06-16-06
Posts: 268
iTrader: 0 / 0%
Latest Blog:
None

ali_420 is on the right pathali_420 is on the right pathali_420 is on the right path
Hey,
for the redirect, replace the lines:

PHP Code:
if ( $Sent )
    {
      echo(
"<p class=\"warning\">Thank you, your message has been sent. We will be in contact with you shortly.</p>\n");
      unset(
$Name$Email);
    } 
with
PHP Code:
$redirectUrl='http://www.example.com/where-you-want-to-redirect.html';
if ( 
$Sent )
    {
       
header('location:'.$redirectUrl);
       die;
  } 
P.S you want to give it a try by filling in the form and seeing if the email is actually sent etc.

Last edited by ali_420 : 07-31-2006 at 02:19 PM.
ali_420 is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-01-2006, 02:43 AM   #18 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
Wooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooooooo hoooooooooooooooooooooooooooooooooooooooo

THANKS ALI YOU ARE AMAZING!!

Rep added!

.~Optix~.
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-01-2006, 03:10 AM   #19 (permalink)
Inactive
 
ali_420's Avatar
 
Join Date: 06-16-06
Posts: 268
iTrader: 0 / 0%
Latest Blog:
None

ali_420 is on the right pathali_420 is on the right pathali_420 is on the right path
I know . Feel free to pm me if you need more help later on (which you will)
ali_420 is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-01-2006, 03:42 AM   #20 (permalink)
Contributing Member
 
Optix's Avatar
 
Join Date: 07-24-06
Location: UK
Posts: 149
iTrader: 0 / 0%
Latest Blog:
None

Optix is liked by many
Send a message via AIM to Optix Send a message via MSN to Optix
lol thanks for the offer dude. and i'll prolly take it up ;p

.~Optix~.
Optix is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to submit an email form natcguerreiro Coding Forum 7 12-05-2007 06:42 PM
Why won't my php form email results? watley Coding Forum 5 10-26-2007 07:36 AM
Email form headaches rearadmiral Coding Forum 2 06-15-2007 06:52 AM
EMAIL FORM Rossco Web Design Lobby 3 10-29-2006 10:07 AM
Input (FORM) - Output (EMAIL)...Help me! maptomal Coding Forum 1 05-07-2006 12:23 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory