Jump to content

simple email submission


websime

Recommended Posts

hey, first post here, not a phpfreak, just getting me toes wet =]

 

so, I want to accomplish a simple thing here...

http://www.namastenutrition.net/mock.html

 

That is just a jpg of the site I am coding, but you can see the field on the left side I am working with.

 

This is what I am trying to do:

1.  User enters their email address

2.  User clicks Sign Up!

3.  User is sent to index_thanks.html

4.  Users e-mail address is emailed to my e-mail address.

 

I know this is realllly simple, I have implemented a contact.php page successfully, but when I try to edit it down, I get errors.

 

If anyone can help me out here, it would be most appreciated!!!

Thanks,

sime

Link to comment
Share on other sites

Honestly if you want a mailing list you should create a database and just have the mail address added along with there name ect. Then use your mailing client to send a mass message rather than having them send you their email address add that to you contacts list.

 

It's honestly a simply registration form, a little basic error checking and  database connection. I could help you with some of the coding if you want send me a PM and I'll get back to you.

Link to comment
Share on other sites

Hi there,

 

For something simple like this, I usually use a basic 2 page submission form... something like the following...

 

signup.php

<html>
<head>
<title>Signup</title>
</head>

<body>
<form action="thanks.php" method="post">
	<table border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td>
			Name:</td>
			<td>
			<input type="text" name="name" /></td>
		</tr>
		<tr>
			<td>
			Email Address:</td>
			<td>
			<input type="text" name="email" /></td>
		</tr>
		<tr>
			<td colspan="2">
			<input type="submit" name="Submit" value="Submit" /> | <input type="reset" name="Reset" value="Start Again" /></td>
		</tr>
	</table>
</form>
</body>
</html>

 

and then for error checking and email submission I use

 

thanks.php


<?php

if(!isset($_POST['Submit']))
	{
	header( 'location: http://www.domain.com/signup.php' );  //this just stops people being able to goto thanks.php 
	// and submit blank forms
	}
	else{

//gather info from previous page
$name = $_POST['name'];
$email = $_POST['email'];

//check that fields are not blank
if(empty($name))
	{ echo("Name field is blank.  Please enter your name");
	}
if(empty($email))
	{ echo("Email field is blank.  Please enter your email");
	}

//check for valid email address function
function CheckMail($email)
	{
		if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$", $email)) { return true; }
		else { return false; }
	}

	if(!empty($name) && !empty($email))
		{
			if(CheckMail($email) == false) // if email address is invalid
				{
				echo("Ut Oh... your email address is broken... please fix it!");
				}
			if(CheckMail($email) == true) // if email address is valid
				{
					//send info via email.
					$sendTo = "youremail@yourdomain.com";  // your email address
					$subject = "new email submission"; //subject of email
					$message = "
						<html><head><title>New Email Submission</title></head>
						<body>
						<p>Name: $name</p>
						<p>Email Address: $email</p>
						</body>
						</html>
						";

					$header = "FROM: <$email>\r\nContent-type: text/html; charset=ISO-8859-1\r\n"; 
					mail($sendTo, $subject, $message, $header);

					echo("Thank you for your submission.  You will now be added to our database");	
				}
		}


}
?>

 

I find this piece of code works really well... and because it sends emails in html you can play around with it and customise it however you want...

 

Hope this helps...

Link to comment
Share on other sites

My php.ini setting are this

--------------------------

[mail function]

; For Win32 only.

 

SMTP = mail.technology-uprising.com

smtp_port = 25

 

; For Win32 only.

sendmail_from = ahtasham82@gmail.com

 

And error is

 

not able to connect to mail server

 

 

please help me i want to send a simple email using php mail function

thanks

Link to comment
Share on other sites

Hey jonahpup

 

I went with your code setup and it pretty much worked great!  Thanks.

 

It seemed to take the info okay and it sent the 'success' message to the browser window.

 

The only glitch is that it did not send the e-mail to me with the entered information!

 

Do I need to do anything thru the hosting account? set up a database or anything?

 

Thanks, also, can anyone tell me why I cannot send private messages??

 

 

Hi there,

 

For something simple like this, I usually use a basic 2 page submission form... something like the following...

 

signup.php

<html>
<head>
<title>Signup</title>
</head>

<body>
<form action="thanks.php" method="post">
	<table border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td>
			Name:</td>
			<td>
			<input type="text" name="name" /></td>
		</tr>
		<tr>
			<td>
			Email Address:</td>
			<td>
			<input type="text" name="email" /></td>
		</tr>
		<tr>
			<td colspan="2">
			<input type="submit" name="Submit" value="Submit" /> | <input type="reset" name="Reset" value="Start Again" /></td>
		</tr>
	</table>
</form>
</body>
</html>

 

and then for error checking and email submission I use

 

thanks.php


<?php

if(!isset($_POST['Submit']))
	{
	header( 'location: http://www.domain.com/signup.php' );  //this just stops people being able to goto thanks.php 
	// and submit blank forms
	}
	else{

//gather info from previous page
$name = $_POST['name'];
$email = $_POST['email'];

//check that fields are not blank
if(empty($name))
	{ echo("Name field is blank.  Please enter your name");
	}
if(empty($email))
	{ echo("Email field is blank.  Please enter your email");
	}

//check for valid email address function
function CheckMail($email)
	{
		if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$", $email)) { return true; }
		else { return false; }
	}

	if(!empty($name) && !empty($email))
		{
			if(CheckMail($email) == false) // if email address is invalid
				{
				echo("Ut Oh... your email address is broken... please fix it!");
				}
			if(CheckMail($email) == true) // if email address is valid
				{
					//send info via email.
					$sendTo = "youremail@yourdomain.com";  // your email address
					$subject = "new email submission"; //subject of email
					$message = "
						<html><head><title>New Email Submission</title></head>
						<body>
						<p>Name: $name</p>
						<p>Email Address: $email</p>
						</body>
						</html>
						";

					$header = "FROM: <$email>\r\nContent-type: text/html; charset=ISO-8859-1\r\n"; 
					mail($sendTo, $subject, $message, $header);

					echo("Thank you for your submission.  You will now be added to our database");	
				}
		}


}
?>

 

I find this piece of code works really well... and because it sends emails in html you can play around with it and customise it however you want...

 

Hope this helps...

Link to comment
Share on other sites

You can't PM until you get 10 posts.

 

Check your error log for a mail error and make sure mail is supported.

 

Well, that advice got me looking into the issue thru the hosting CP and found a form mail .asp solution that go daddy offers, which did exactly what I was looking for and nothing more.

 

This one is solved for now but I will be getting in touch via PM as soon as I can to discuss mailing lists!

 

thanks to everyone for being helpful and kind.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.