email of order form

indiana

New Member
Messages
5
Reaction score
0
Points
0
Hi everyone, I have upgraded my php to level 2, hoping that this would allow my php script for sending the results of an order form to work. It has not. But as I am very new to all web programming, and copied most of the code from an example, I wondered whether it was a problem with the code. Here is what I have:

<?php
require_once "Order.php";
$mailto = "order@titan-tech.co.uk";
$subject = "Titan-Tech Order Form";

$body = "The following confirms the details of your order:\n";
$body .= "\n\n";
$body .= "Name: " . $Fname . "\n";
$body .= "Surname: " . $Sname . "\n";
$body .= "Email: " . $email . "\n";
$body .= "Budget: " . $budget . "\n";
$body .= "\n\n";
$body .= "Computer Use: " . $Compuse . "\n";
$body .= "Specific Requirements: " . $SpecCom . "\n";
$body .= "Elite: " . $Elite . "\n";
$body .= "Monitor: " . $monitor . "\n";
$body .= "Keyboard: " . $keyboard . "\n";
$body .= "Mouse: " . $mouse . "\n";
$body .= "Speakers: " . $speakers . "\n";
$body .= "\n";
$host = "ssl://smtp.gmail.com";
$port = 465;
$username = "titantechcomputers@googlemail.com";
$password = "***********";
$headers = array ('From' => $email,
'To' => $mailto,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password, 'persist' => true));
$mail = $smtp->send($mailto, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>

I get the error message::dunno:

Fatal error: Class 'Mail' not found in /home/indiana/public_html/Order.php on line 31


Help is much appreciated, thank you;)
 
Last edited:

VPmase

New Member
Messages
914
Reaction score
1
Points
0
I'm not sure PEAR is 100% enabled on free servers. Maybe an admin can correct me.
 

indiana

New Member
Messages
5
Reaction score
0
Points
0
Thank you for your reply. Do I need to use this form of mail, or should just:

mail()

work??
 

indiana

New Member
Messages
5
Reaction score
0
Points
0
I just tried that, and apparently mail() is not enabled yet. I guess I need the next level of permissions...
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
no. you don't need advanced. it should work. post your new code.
 

indiana

New Member
Messages
5
Reaction score
0
Points
0
It doesnt seem to be working, still get the 'mail() is dissabled' message. Heres the code:

<?
$mailto = "order@titan-tech.co.uk";
$subject = "Titan-Tech Order Form";

$body = "The following confirms the details of your order:\n";
$body .= "\n\n";
$body .= "Name: " . $Fname . "\n";
$body .= "Surname: " . $Sname . "\n";
$body .= "Email: " . $email . "\n";
$body .= "Budget: £" . $budget . "\n";
$body .= "\n\n";
$body .= "Computer Use: " . $Compuse . "\n";
$body .= "Specific Requirements: " . $SpecCom . "\n";
$body .= "Elite: " . $Elite . "\n";
$body .= "Monitor: " . $monitor . "\n";
$body .= "Keyboard: " . $keyboard . "\n";
$body .= "Mouse: " . $mouse . "\n";
$body .= "Speakers: " . $speakers . "\n";
$body .= "\n";


mail($mailto, $subject, $body);
mail($email, $subject, $body);


if (mail($to, $subject, $body)) {
echo "The following information was sent:";
echo "<br>\n";
echo "<pre>\n";
echo $body;
echo "</pre>\n";
} else {
echo("<p>Message delivery failed...</p>");
}

?>

Thanks for the help again
 

sunils

New Member
Messages
2,266
Reaction score
0
Points
0
Try the below code. its just the similar one only.



$to = "order@titan-tech.co.uk";
$subject = "Titan-Tech Order Form";

$message = "The following confirms the details of your order:\n";
$message .= "\n\n";
$message .= "Name: " . $Fname . "\n";
$message .= "Surname: " . $Sname . "\n";
$message .= "Email: " . $email . "\n";
$message .= "Budget: £" . $budget . "\n";
$message .= "\n\n";
$message .= "Computer Use: " . $Compuse . "\n";
$message .= "Specific Requirements: " . $SpecCom . "\n";
$message .= "Elite: " . $Elite . "\n";
$message .= "Monitor: " . $monitor . "\n";
$message .= "Keyboard: " . $keyboard . "\n";
$message .= "Mouse: " . $mouse . "\n";
$message .= "Speakers: " . $speakers . "\n";
$message .= "\n";

$from = "no-reply@titan-tech.co.uk";
$headers = "From: $from";


if (mail($to,$subject,$message,$headers)) {
echo "The following information was sent:";
echo "<br>\n";
echo "<pre>\n";
echo $body;
echo "</pre>\n";
} else {
echo("<p>Message delivery failed...</p>");
}
 
Last edited:

indiana

New Member
Messages
5
Reaction score
0
Points
0
Thank you, that now sends an email to the address at the top, but for some reason none of the variables are being sent. Why wouldnt it send the form information? Do I have to define them or something? at the moment those variables are simply the dollar sign followed by the name I gave the it in the form input box, i.e.

<select name="speakers">

and then the variable $speakers
Edit:
Perhaps for the same reason it doesnt send the email to the email address entered, even once I coppied the same code to send it to the second address:

<?

$to = "order@titan-tech.co.uk";
$subject = "Titan-Tech Order Form";

$message = "The following confirms the details of your order:\n";
$message .= "\n\n";
$message .= "Name: " . $Fname . "\n";
$message .= "Surname: " . $Sname . "\n";
$message .= "Email: " . $email . "\n";
$message .= "Budget: £" . $budget . "\n";
$message .= "\n\n";
$message .= "Computer Use: " . $Compuse . "\n";
$message .= "Specific Requirements: " . $SpecCom . "\n";
$message .= "Elite: " . $Elite . "\n";
$message .= "Monitor: " . $monitor . "\n";
$message .= "Keyboard: " . $keyboard . "\n";
$message .= "Mouse: " . $mouse . "\n";
$message .= "Speakers: " . $speakers . "\n";
$message .= "\n";

$from = "no-reply@titan-tech.co.uk";
$headers = "From: $from";

if (mail($email,$subject,$message,$headers)) {
echo "You will recieve a conformation email to your address";
echo "<br>\n";

} else {
echo("<p>Message delivery failed...</p>");
}

if (mail($to,$subject,$message,$headers)) {
echo "The following information was sent to Titan-Tech:";
echo "<br>\n";
echo "<pre>\n";
echo $message;
echo "</pre>\n";
} else {
echo("<p>Message delivery failed...</p>");
}
?>
Edit:
I just added the required:

$Fname = $_POST['Fname'];
$Sname = $_POST['Sname'];
$email = $_POST['email'];
$budget = $_POST['budget'];
$Compuse = $_POST['Compuse'];
$SpecCom = $_POST['SpecCom'];
$Elite = $_POST['Elite'];
$monitor = $_POST['monitor'];
$keyboard = $_POST['keyboard'];
$mouse = $_POST['mouse'];
$speakers = $_POST['speakers'];

but it still doesnt work
Edit:
Correct that, It now works!!!! thanks for the help
 
Last edited:
Top