Current location: Hot Scripts Forums » Programming Languages » PHP » Simple order PHP form to Email


Simple order PHP form to Email

Reply
  #1 (permalink)  
Old 01-05-06, 03:36 AM
wearetwo wearetwo is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Simple order PHP form to Email

Hey guys,

I am pretty clueless when it comes to php. Yikes!

I am in need of a simple form script that will get the data one inputs in a form and email them to me. Specifically, this is the (HTML) form I have:

Code:
<form method="post" action="sendmail.php">

<b>information</b>

<p>

Name: <input type="text" size="7" name="name"> <p>

Phone Number: <input type="text" name="phone"> <p>

Email Address <input type="text" name="email"> <p>

<hr>

<b>Further information</b><p>

Country: 

<SELECT NAME="state" SIZE="1">
<OPTION SELECTED>Blue
<OPTION>Red
<OPTION>Yellow
<OPTION>Green
<OPTION>Black
<OPTION>Orange
<OPTION>Purple
</SELECT>

<p>

Number : <input type=text size=2 name="purchase"><p>

URL: http://<input type=text name="link"><p>

Image File: <INPUT TYPE="file" NAME="attachedfile" MAXLENGTH=50 ALLOW="text/*" ><p>

<b>Extra Comments</b><p>

<TEXTAREA NAME="comment" ROWS=6 COLS=40>
</TEXTAREA>

<hr>

<INPUT TYPE="submit">
<INPUT TYPE="reset">

</form>
I have tried to use "php mail(" function but apparently php mail function can't have more than five variables...

I did this,
PHP Code:

<?

  $email 
$_REQUEST['namel'] ;
  
$message $_REQUEST['phone'] ;
  
$message $_REQUEST['email'] ;
  
$message $_REQUEST['state'] ;
  
$message $_REQUEST['purchase'] ;
  
$message $_REQUEST['link'] ;
  
$message $_REQUEST['attachedfile'] ;
  
$message $_REQUEST['method'] ;
  
$message $_REQUEST['comment'] ;

  
mail("email@email.com",$name,$phone,$email,$state,$purchae,$link,$method,$comment);

?>
followed by mail( which spewed me many errors,

basically, is there a way to get all the data and have them mailed at to me? the "names" I have is

name=name
name=phone
name=email
name=state
name=purchase
name=link
name=attachedfile
name=method
name=comment

Thanks very much

Last edited by wearetwo; 01-05-06 at 03:41 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-05-06, 04:56 AM
johndapunk johndapunk is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Dunno if this will at all help you (kinda practice for me also, but here is the source i worked out.)
Code:
<html>
<head>
</head>
<body>
<form action="answer.php" method="post">
Name: <input type="text" name="name"><br>
Age: <input type="text" name="age"><br>
Email: <input type="text" name="email"><br>
<input type="submit" value="submit">
</form>
</body></html>
Code:
<?php
	$to = "johndapunk@gmail.com"; 
	$useremail = $_POST['email'];
	$name = $_POST['name'];
	$age = $_POST['age'];
	$subject= "subject here";
			
			$message="
			$name has done something.
			
			<table border=1 bgcolor=black>
			<tr bgcolor=76A5D5>
			<th width=125><font color=white>Age</font>
			
			<tr>
			<td><font color=white>".$age."
			
			</table>
			Thanks
			
			";
			
			$headers = "FROM: '$name' <$useremail>\r\n";
			$headers .= "MIME-Version: 1.0\r\n";
			$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

			mail($to, $subject, $message, $headers);

echo ("Should be successful.");
?>
Also depends on whether you have a mailserver to connect to (as i do not, so I could not get a 100% reading of whether those scripts will work or not.) Although, I believe they should work... other then the fatal error I got for not being able to connect to a mailserver at localhost, all parse errors were buffed out.

Enjoy, and good luck.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-05-06, 06:05 AM
olaf's Avatar
olaf olaf is offline
Newbie Coder
 
Join Date: Sep 2004
Location: The Netherlands
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
or try this easy to use php snippet:

http://www.finalwebsites.com/snippets.php?id=3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 01-05-06, 06:29 AM
wearetwo wearetwo is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks john! That worked perferctly! yay!

One thing though, in my form one of the input type is a file attatchment, ie.
Code:
Attatchment: <INPUT TYPE="file" NAME="attachedfile" MAXLENGTH=50 ALLOW="text/*" >
How will I get this attatchment to mail it self to my email?

thanks very much!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 01-05-06, 06:35 AM
olaf's Avatar
olaf olaf is offline
Newbie Coder
 
Join Date: Sep 2004
Location: The Netherlands
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,

sending files bij mail via a webform is much more complicated:

Check in this direction:

1. form submit
2. file upload
3. build mimemail

On my website is an example script how to send an e-mail with one attachement.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 01-05-06, 12:21 PM
johndapunk johndapunk is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Great, glad to be of service.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 01-05-06, 03:22 PM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
A thing to keep in mind is the header injection problem going around at the moment.

I would search around a bit to find more information on it but one thing to do ( as I understand it ) is to :

PHP Code:



$useremail 
$_POST['email'];
$useremail preg_replace("/\r/"""$useremail);
$useremail preg_replace("/\n/"""$useremail); 
Which is supposed to help by stopping the spammer exploiting that field of your form?

Anthony
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 01-06-06, 04:28 AM
wearetwo wearetwo is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Hi,

sending files bij mail via a webform is much more complicated:
aww. thats terrible news!

It is possible though...is it? via php?

I'd appreciate if someone can come up with a very simple uploading form!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 01-06-06, 04:33 AM
olaf's Avatar
olaf olaf is offline
Newbie Coder
 
Join Date: Sep 2004
Location: The Netherlands
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by wearetwo
aww. thats terrible news!

It is possible though...is it? via php?

I'd appreciate if someone can come up with a very simple uploading form!
of course it's possible, first read this about the upload: http://www.google.com/search?hl=en&l...rm&btnG=Search

and then try this article over writing a mime mail script: http://www.phpbuilder.com/columns/ka...07.php3?aid=69
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
simple email pkcidstudio Script Requests 1 11-19-05 05:21 AM
can you use php to get someone's email address from a mailer? pagetta PHP 8 11-11-05 06:36 AM
why C#? Also help with an email form dathandawg Windows .NET Programming 1 11-08-05 04:19 PM
Preventing email form abuse LunarOrbit Perl 3 10-04-03 10:55 PM


All times are GMT -5. The time now is 01:14 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.