Jump to content

Mail System


inquisitive

Recommended Posts

Below is the code to contact2.php...contact.php is basically an html page with the form that posts the form data to this page...now my problem is when I try to view this page on the server after clicking the submit button I am greeted with a totally blank white screen.  Haven't really run into this problem before....HELP!

 

<?php 

$submit = $_POST["Submit"];
if ($submit == "Submit") {

$db="334311_guttergraphics"; 
$link = mysql_connect("mysql5-14.wc1", "*******", "******");
if (! $link)
die("Our database is experiencing technical difficulties. Please contact our Webmaster");
else{
mysql_select_db($db , $link)
or die("Select DB Error: ".mysql_error());
}

//check for valid email address
  if(stristr($_POST['email'], "@") === FALSE) { 
  echo "<br><br><br><br><table width='400' border='1' bgcolor='white' cellspacing='0' cellpadding='0' align='center'>
                <tr>
                  <td><a href='#' onClick='history.go(-1)'>Back</a><br> Email Address was Invalid.<br> Please verify that you have entered a proper email address.</td>
                </tr>
              </table>" ; exit();
  } 
  
$form1 = $_POST["firstname"];
$form2 = $_POST["lastname"];
$form3 = $_POST["address1"];
$form4 = $_POST["address2"];
$form5 = $_POST["city"];
$form6 = $_POST["state"];
$form7 = $_POST["zip"];
$form8 = $_POST["homephone"];
$form9 = $_POST["altphone"];
$form11 = $_POST["email"];
$form13 = $_POST["comment"];
  
//loop through _post array and insert into database
$query = "INSERT INTO contact (id,firstname,lastname,address1,address2,city,state,zip,homephone,altphone,email,comment)
VALUES('','$form1', '$form2','$form3','$form4','$form5','$form6','$form7','$form8','$form9','$form11','$form13')";
$result = mysql_query($query) or die(mysql_error());

// Send email
require_once "Mail.php";

$to = "[email protected], [email protected]";
$from = "[email protected]";
$subject = "Quote - ".$_SERVER['HTTP_HOST']." at ".$_POST["time"];
$message = "\nFirst: " .$form1 ."\n" ."Last: " .$form2 ."\nCity: " .$form5 ."\n" ."State: " .$form6."\nPhone: ".$form8."\n" ."Address1: " .$form3."\n" ."Address2: " .$form4 ."\nZipcode: " .$form7 ."\nHome Phone: " .$form8 ."\nAlternate Phone: " .$form9 ."\nEmail: " .$form11 ."\nComments: ".$form13.;

$host = "mail.guttergraphics.com";
$username = "[email protected]";
$password = "portable";

$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, $message);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/125292-mail-system/
Share on other sites

Php gets parsed by the server so only output is displayed, in this case no echo/print no html.

 

But it would help if you could refraise your question? I may have misunderstood what you where trying ask. Also please use code tags.

 

One more thing do NOT post database information like passwords and other sensitive info, you don`t know hoe mite take attvantage of that information!

Link to comment
https://forums.phpfreaks.com/topic/125292-mail-system/#findComment-649413
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.