Contact Form Send

Hello I have this Form but it is not sending not sure
why though I may be missing something:

HTML

<form id="contactform" action="pdcontactengine.php" method="post">
                                    <label class="title-form">*Name</label><br>
                                    <input type="text" name="Firstandlastname" class="inputs" placeholder="Enter First & Last Name">
                                    <label class="title-form">*Email</label><br>
                                    <input type="text" name="Emailaddress" class="inputs" placeholder="Enter Email Address">
                                    <label class="title-form">*Message</label><br>
                                    <textarea name="Message" class="messagebox" placeholder="Enter Message"></textarea>
                                    <input type="submit" name="button" class=" btn btn-default form-btn">
                                </form>

PHP

<?php
$EmailFrom = "Preferred Dentist Customer";
$EmailTo = "csosa@iogproducts.com";
$Subject = "Hello";
$Name = Trim(stripslashes($_POST['Firstandlastname'])); 
$Email = Trim(stripslashes($_POST['Emailaddress'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Firstandlastname: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Emailaddress: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

$EmailFrom is not a valid hosted email address.

$success = mail($EmailTo, $Subject, $Body, "From: $EmailFrom <$EmailTo>");

… assuming $EmailTo is a valid hosted email address.

it is

that does not have to be an actual email though right?

What is Trim? Is it your custom function or typo in trim?

$Name = Trim(stripslashes($_POST['Firstandlastname']));

that actually was already there it worked in a previous form engine I did…not
sure exactly what is is…

It does if used as you had it

"From: <$EmailFrom>"

Notice I changed it to show the name and use the actual email like so.

$success = mail($EmailTo, $Subject, $Body, "From: $EmailFrom <$EmailTo>");

So when seeing email in client, the email will show FROM Preferred Dentist Customer

PHP functions are case-insensitive.

1 Like

hmm this still didnt send me anything.
The website is not actually a real domain yet but it is
in a live host. Should it still work or is that issue that I dont have
it in a real domain? Here is where I have it: PAGE

Have you added an email for this domain, e.g. info@impactograph.com
THIS should be the address the email is sent from and why I was asking about the “Hosted Address”.

A modified version of your code would then be like so.

$From = "Preferred Dentist Customer";
$EmailFrom = "info@impactograph.com";
$EmailTo = "csosa@iogproducts.com";
$Subject = "Hello";
$Name = Trim(stripslashes($_POST['Firstandlastname'])); 
$Email = Trim(stripslashes($_POST['Emailaddress'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Firstandlastname: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Emailaddress: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: $From <$EmailFrom>");

I dont but I have a similar php code that is working fine, I think its because it is
within the server and it is not a real domain that it is not functioning. I have that website
in a subfolder.

This is how I have my previous php code for impactograph.com for the contact form:

<?php
$EmailFrom = "Customer";
$EmailTo = "dtermine@iogproducts.com";
$Subject = "Impact-O-Graph Devices Customer Information";
$Name = Trim(stripslashes($_POST['FullName'])); 
$Email = Trim(stripslashes($_POST['EmailAddress'])); 
$Company = Trim(stripslashes($_POST['CompanyName'])); 
$Phone = Trim(stripslashes($_POST['PhoneNumber'])); 
$Address = Trim(stripslashes($_POST['CustomerAddress'])); 
$Comments = Trim(stripslashes($_POST['UserComments'])); 
$Referral = Trim(stripslashes($_POST['Howdidyouhearaboutus'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Full Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email Address: "; 
$Body .= $Email;
$Body .= "\n";
$Body .= "Company Name: ";
$Body .= $Company;
$Body .= "\n";
$Body .= "Phone Number: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Customer Address: ";
$Body .= $Address;
$Body .= "\n";
$Body .= "User Comments: ";
$Body .= $Comments;
$Body .= "\n";
$Body .= "How Did You Hear About Us?: "; 
$Body .= $Referral;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php#contactform\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}

?>

almost the same thing…

Sorry guys, am I missing something here?

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

Isn’t that completely pointless?

Ya, I wasn’t even going to go there. Just dealing with email issue.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.