Solved

Simple Email Sign Up Button

Posted on 2008-06-17
10
648 Views
Last Modified: 2008-06-19
Hi,
Having some confusion about how to set up an input box for people to register their email.

So all I need is this
1. an input box for the user to put their email
2.an button for them to click register
3.after the user clicks register, their email adress is sent to an email address of my choosing (please specify in your answer where i specifiy this email).
4.An auto generated message is sent to the user's email thanking them for registering their email.


Can you please provide the comeplete code that would allow me to do this in either CSS/XHTML or PHP
.
Thanks
   
0
Comment
Question by:djmichaelray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 14

Accepted Solution

by:
Vel Eous earned 500 total points
ID: 21807668
How about:
<?PHP
 
if ( isset ( $_POST['submit'] ) )
{
 
	$user_email = $_POST['email'];
	
	$to = 'you@yourdomain.com'; // your email address here
	$subject = 'New sign up'; // change this as desired
	$message = 'A New user has signed up, email address: ' . $user_email; // change this as desired
	
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	$headers .= 'From: no-reply@yourdomain.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
				
	mail ( $to, $subject, $message, $headers );
	
	$to = $user_email;
	$subject = 'no-reply@yourdomain.com'; // yourdomain here
	$message = 'Thank you for signing up to yourdomain.com'; // change this as desired
	
	mail ( $to, $subject, $message, $headers );
 
}
 
?>
 
<form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post">
	<input type="text" name="email" /><input type="submit" value="sign up" />
</form>

Open in new window

0
 
LVL 14

Expert Comment

by:Vel Eous
ID: 21807679
Sorry just seen an error:

replace:

<input type="submit" value="sign up" />


With:

<input type="submit" value="sign up" name="submit" />
0
 

Author Comment

by:djmichaelray
ID: 21807870
i have an example of your code at http://www.djmichaelray.com/neverdie/index.html   it generates an error when you click on submit.


can you brefiely explain why please then ill award the points cause the rest of the code looks good.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:Vel Eous
ID: 21807964
You have the page saved as .html when it should be .php
0
 

Author Comment

by:djmichaelray
ID: 21808915
sorry bro its still not working
0
 
LVL 14

Expert Comment

by:Vel Eous
ID: 21809087
Try the following.  If you see a message "Emails sent", check your spam filters as that is a common problem.
<?PHP
 
if ( isset ( $_POST['submit'] ) )
{
 
	$user_email = $_POST['email'];
	
	$to = 'you@yourdomain.com'; // your email address here
	$subject = 'New sign up'; // change this as desired
	$message = 'A New user has signed up, email address: ' . $user_email; // change this as desired
	
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	$headers .= 'From: no-reply@yourdomain.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
				
	mail ( $to, $subject, $message, $headers );
	
	$to = $user_email;
	$subject = 'no-reply@yourdomain.com'; // yourdomain here
	$message = 'Thank you for signing up to yourdomain.com'; // change this as desired
	
	mail ( $to, $subject, $message, $headers );
	
	echo 'Emails sent';
 
}
 
?>
 
<form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post">
	<input type="text" name="email" /><input type="submit" value="sign up" name="submit" />
</form>

Open in new window

0
 
LVL 18

Expert Comment

by:Matthew Kelly
ID: 21809409
www.djmichaelray.com is hosted at GoDaddy. GoDaddy blocks port 25. Port 3535 is available for email traffic.

Not sure how to help the poster, but hopefully that helps out another expert.
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 21810293
You named the submit button 'submit'.  Name it something else.

If the email is not being sent, but the form does submit, follow matthewstevenkelly's advice.  Make sure you have a server up, that it is properly configured for your host, and that you can actually send mail through it outside of the website.  
0
 
LVL 14

Expert Comment

by:Vel Eous
ID: 21812361
>> You named the submit button 'submit'.  Name it something else.

The name of the submit button is only there to test for the form being sent.  It's name will not affect the functioning of the script.
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 21816800
My apologies...the 'submit' name issue presents itself only when using javascript to submit the form.  The button should still work.

>>> it generates an error when you click on submit.

Did you find the source of this problem?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question