Advertisement

08.30.2006 at 10:22AM PDT, ID: 21972873
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

How to e-mail information from a simple form, using PHP.

Asked by jgohil in PHP Scripting Language

Tags: ,

I actually followed a tutorial which got everything working for me.

I used the code from this tutorial.  I already created the form and this is the code for the 'Contact.php' page:

http://php.about.com/od/phpapplications/ss/form_mail_3.htm


Everything was working at that point with the exception of actually sending the mail.  I believe it's because the SMTP server needs authentication.  So then I followed another tutorial, because the site is on a server that has PEAR installed.  This is the code I used to authenticate:

http://email.about.com/od/emailprogrammingtips/qt/et073006.htm


Now, I got that part of the code to work, and I implanted it into the top part of the 'Contact.php', (and configured the authentication options) it seems to work, but it's not using the data from the form.  I know I need to somehow combine these two things, but I'm not sure how.

The overall gist of what i'm trying to do is rather simple...

I'm just creating a form that has a few fields (name, address, etc...) and when the submit button is hit, it should e-mail the info. from those fields to a designated email address.  If there is a simpler way of doing this, please let me know.  

If you want to see the form that I've actually created, you can view it here:

http://www.smartofficeadvisors.com/survey1.php

From there, when the user hits "submit" it transfer the information to:

http://www.smartofficeadvisors.com/contact2.php

for which the source looks like this:

<!-- The PHP Authentication Script -->

<?php
require_once "Mail.php";

$from = "from <user@dijitalmedia.com>";
$to = "bcast <bcast@smartofficeadvisors.com>";
$subject = "Pig Card";
$body = "Hi,\n\nHow are you?";

$host = "mail.dijitalmedia.com";
$username = "user@dijitalmedia.com";
$password = "passwordhere";

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
 }
?>
<!-- End PHP Authentication Script -->


<!-- The script from the email send tutorial -->
<?php
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Chair Survey Results";

$fields = array();
$fields{"Name"} = "Name";
$fields{"industry"} = "Industry";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$headers2 = "From: info@smartofficeadvisors.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us.
Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.smartofficeadvisors.com";

if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.smartofficeadvisors.com/thankyou.php" );}
else
{print "We encountered an error sending your mail, please notify ithelp@smartofficeadvisors.com"; }
}
}
?>


<!-- End Tutorial email sending script -->



I hope all of this has been clear, and I'm certain this should be easy for someone who knows what they're doing.  Thanks in advance.

J. GohilStart Free Trial
 
Loading Advertisement...
 
[+][-]08.30.2006 at 11:05AM PDT, ID: 17422688

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.31.2006 at 07:38AM PDT, ID: 17429292

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.31.2006 at 08:45AM PDT, ID: 17429964

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.31.2006 at 08:51AM PDT, ID: 17430005

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.31.2006 at 08:54AM PDT, ID: 17430030

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.31.2006 at 09:04AM PDT, ID: 17430103

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.02.2006 at 03:11AM PST, ID: 17857046

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]11.02.2006 at 06:52AM PST, ID: 17858322

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Tags: address, php
Sign Up Now!
Solution Provided By: inxil
Participating Experts: 1
Solution Grade: A
 
 
[+][-]11.21.2006 at 11:08AM PST, ID: 17989647

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]11.26.2006 at 05:12PM PST, ID: 18016163

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32