Wikiposts
Search
Computer/Internet Issues & Troubleshooting Anyone with questions about the terribly complex world of computers or the internet should try here. NOT FOR REPORTING ISSUES WITH PPRuNe FORUMS! Please use the subforum "PPRuNe Problems or Queries."

PHP query

Thread Tools
 
Search this Thread
 
Old 28th Oct 2010, 11:09
  #1 (permalink)  
Per Ardua ad Astraeus
Thread Starter
 
Join Date: Mar 2000
Location: UK
Posts: 18,579
Likes: 0
Received 0 Likes on 0 Posts
PHP query

I have a php mailer form on a site. I would like to return the following contents of the incoming email in a php generated email reply with additional text added.

$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"Message"} = "Booking Request";

Any gurus on line? Google seems devoid of help here.
BOAC is offline  
Old 28th Oct 2010, 23:05
  #2 (permalink)  
 
Join Date: Oct 2009
Location: Greece
Age: 84
Posts: 63
Likes: 0
Received 0 Likes on 0 Posts
I am not quite sure what you are trying to say...

So.. I'll take a guess, and answer that

You have a php form. Lets say that you have something you rent, they go online, fill out the form, and when they click submit, you then get an email with their information and request


Name [________]
Email [_________]
Phone [_______]

Booking Request
[___________________________]
[____________________________]
[____________________________]
^That is how the form would probably look


The HTML of the form would have..
Code:
<html>
<head>
</head>
<body>
<form target="mailer.php" action="post">
....etc..
</form>
</body>
</html>

Mailer PHP will be basically your form letter

Generally, what is best to do is have the actual letter (that gets the text replaced) as a separate file altogether, and included at run-time, but for this explanation we have it all in one.

Note that this simple explanation does not have the added protections you need to have (to prevent spamming, hacking and assholes)
Code:
<?php
// note.. the fields in the form will show up here as variables in the $_POST object as follows
$name = $_POST['name']; //etc etc

//email template
$headers = "From:". $_POST['email']."\r\n"
$subject="Booking request";
$to ="[email protected]";
$body = $_POST['request'];

if (@mail($to, $subject, $body, $headers)) {
		echo("<p>Message sent!</p><pre>" .$body. '</pre>');
		} else {
		echo("<p>Message delivery failed...</p>");
		}
tailstrikecharles is offline  
Old 29th Oct 2010, 08:00
  #3 (permalink)  
Per Ardua ad Astraeus
Thread Starter
 
Join Date: Mar 2000
Location: UK
Posts: 18,579
Likes: 0
Received 0 Likes on 0 Posts
TSC - thanks for replying, but I am confused! How does that return the incoming email from the mailer as a reply with text added to the sender?

PS Not too bothered about 'spamming, hacking and assholes' as the email will not go to me
BOAC is offline  
Old 29th Oct 2010, 12:32
  #4 (permalink)  
 
Join Date: Oct 2009
Location: Greece
Age: 84
Posts: 63
Likes: 0
Received 0 Likes on 0 Posts
Post

How does the process work now?

As far as the 'incoming email' bit, there is no "email" - not really, there is a form on a web page, the user inputs some info to the form, and clicks SUBMIT. then it goes to another page which 'sees' the info that was on the page and concatenates it into text which it then emails out

example
(Previous page had fields, sex, phone, email, firstname)

$title ="Mr. " ;
$recommend_vehicle ="Ford Mustang";
$recommend_vehicle="Volkswaggon Beetle";

if ($sex="F" ) {
$title ="Ms. ";

email_message$ ="Dear ". $title. $firstname . ", how are you today? ";
email_message$ .="I have just the car for you! ";

email_message$ .="You will love your new " . $recommend_vehicle;
email_message$ .=" we will call " .$number. " to arrange delivery ";

...sendmail...



Now, if you have an email address that is already receiving emails, and you want to open them up, "read" them, and send some intelligent email back, thats a bit more complicated, and will depend on the email system you are reading from and need SMTP/IMAP information.

I dont believe your situation is that complicated however..

pm me a link to the page and I'll give it a look, its often more difficult to' explain than show
tailstrikecharles is offline  
Old 29th Oct 2010, 14:05
  #5 (permalink)  
Per Ardua ad Astraeus
Thread Starter
 
Join Date: Mar 2000
Location: UK
Posts: 18,579
Likes: 0
Received 0 Likes on 0 Posts
PM on the way.
BOAC is offline  
Old 29th Oct 2010, 18:23
  #6 (permalink)  
 
Join Date: Oct 2009
Location: Greece
Age: 84
Posts: 63
Likes: 0
Received 0 Likes on 0 Posts
Thumbs up reply sent

It is exactly as I said above.

You are not actually getting an 'incoming email' you are getting the submitted values of a form.
These values you will use to compose an email message that is then sent to the email address the user has specified.

I'll put it up on a demo server as soon as I get off base.
tailstrikecharles is offline  
Old 30th Oct 2010, 18:14
  #7 (permalink)  
 
Join Date: Oct 2009
Location: Greece
Age: 84
Posts: 63
Likes: 0
Received 0 Likes on 0 Posts
Thumbs up sorted!

wasnt much needed doing either.. formatted the code making it easier to read, changed the variable names to make it easier to follow and added some comments
tailstrikecharles is offline  
Old 30th Oct 2010, 19:23
  #8 (permalink)  
Per Ardua ad Astraeus
Thread Starter
 
Join Date: Mar 2000
Location: UK
Posts: 18,579
Likes: 0
Received 0 Likes on 0 Posts
Thank you Doctor - feeling better already!
BOAC is offline  

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service

Copyright © 2024 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.