WEBMAIL PROCESSING SCRIPT 99% FINISHED but surely a word incorrect...



Ok I have deleted the question of before because it seems that people had difficulties in understanding it.

I ll try it other way. This is the processing script that usually handles a web form using SMTP authentication. Ok, What you will see as an extra is that there is a SQL query which selects the email of the destination party. It does so by using the ID and table name that you have passed it when you clicked on the link of a row.

You will also see that I have put an "isset", I have done that to prevent the script from firing himself when he is sent the ID and table name. I want the processing script to wait until someone fills out the webform.

Here is the script and I think there is something incorrect in the code

<?php
session_start();

$numero = $_POST['id'];
$tabla = $_POST['tabla'];

if (isset($name, $email, $message)) {

require ('mysqli_connect.php');

$sql ="SELECT email
FROM $tabla
WHERE id
= '".$numero."'";

$result = @mysql_query ($sql);

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

$email_destination = ($row['email']);

}

require_once "Mail.php";

$from = $_POST['email']; // this is actually forwarded from contact.js as this received first the contents of the html form
$subject = $_POST['Name']; // here i use the field subject for name, it doesnt matter
$body = $_POST['message']; // same, comes from contact.js. Contact.js merely sort of validates a little bit the data entered
$to = "$email_destination";

$host = "mail.travel.net";
$port = 26;
$username = "ceo+travel.net";
$password = "mypwd";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' =>$port,
'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>");
}
echo '</div>';

} // IF FIELDS WERE FILLED IN WEBFORM, OTHERWISE, RETURNS FALSE

else (return false};

?>