Jump to content

Mailing form - Can't get it to send


nofx1728

Recommended Posts

I can not figure this out and I'm starting to get really frustrated.  I tried going through your sample code and that didn't work either.  If a field isn't filled out properly the error message comes up as intended, and after I submit the form it redirects me to the correct website as intended.  However, the email of the form information is never being sent back to me.  Can someone please help me.  Here is my code:

 

<?php
// Receiving variables
$item_name = addslashes($_POST['item_name']);
$quantity = addslashes($_POST['quantity']);
$amount = addslashes($_POST['amount']);
$firstname = addslashes($_POST['firstname']);
$lastname = addslashes($_POST['lastname']);
$address1 = addslashes($_POST['address1']);
$address2 = addslashes($_POST['address2']);
$city = addslashes($_POST['city']);
$state = addslashes($_POST['state']);
$zip = addslashes($_POST['zip']);
$company = addslashes($_POST['company']);
$occupation = addslashes($_POST['occupation']);
$email = addslashes($_POST['email']);
$phone1 = addslashes($_POST['phone1']);
$phone2 = addslashes($_POST['phone2']);
$phone3 = addslashes($_POST['phone3']);
$phonetype = addslashes($_POST['phonetype']);

// Validation
if ( $amount < 0)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid amount</font></p>");
}
if ( $amount > 500)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid amount</font></p>");
}

if (strlen($amount) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid amount</font></p>");
}

if (strlen($firstname) <1)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid firstname</font></p>");
}
if (strlen($firstname) >20)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid firstname</font></p>");
}

if (strlen($firstname) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid firstname</font></p>");
}

if (strlen($lastname) <1)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid lastname</font></p>");
}
if (strlen($lastname) >20)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid lastname</font></p>");
}

if (strlen($lastname) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid lastname</font></p>");
}

if (strlen($address1) <1)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid address1</font></p>");
}
if (strlen($address1) >100)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid address1</font></p>");
}

if (strlen($address1) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid address1</font></p>");
}

if (strlen($city) <1)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid city</font></p>");
}
if (strlen($city) >30)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid city</font></p>");
}

if (strlen($city) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid city</font></p>");
}

if (strlen($zip) <5)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid zip</font></p>");
}
if (strlen($zip) >10)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid zip</font></p>");
}

if (strlen($zip) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid zip</font></p>");
}

if (strlen($occupation) <1)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid occupation</font></p>");
}
if (strlen($occupation) >20)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid occupation</font></p>");
}

if (strlen($occupation) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid occupation</font></p>");
}

if (strlen($email) <1)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}
if (strlen($email) >100)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}

if (strlen($email) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}

if (strlen($phone1) <3)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid phone1</font></p>");
}
if (strlen($phone1) >3)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid phone1</font></p>");
}

if (strlen($phone1) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid phone1</font></p>");
}

//Sending Email to form owner
$pfw_header = "From: $email\r\n";
$pfw_subject = "form test";
$pfw_email_to = "nofx1727@yahoo.com";
$pfw_message = "item_name: $item_name\r\n"
. "quantity: $quantity\r\n"
. "amount: $amount\r\n"
. "firstname: $firstname\r\n"
. "lastname: $lastname\r\n"
. "address1: $address1\r\n"
. "address2: $address2\r\n"
. "city: $city\r\n"
. "state: $state\r\n"
. "zip: $zip\r\n"
. "company: $company\r\n"
. "occupation: $occupation\r\n"
. "email: $email\r\n"
. "phone1: $phone1\r\n"
. "phone2: $phone2\r\n"
. "phone3: $phone3\r\n"
. "phonetype: $phonetype\r\n";
mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header );
header("Location: https://www.paypal.com/cgi-bin/webscr");

?>

Link to comment
Share on other sites

Ok... this is probably the dumbest question anyone has ever written... but I just got off the phone with godaddy and they said I need to switch my hosting from windows to linux in order for the script to work.

 

1.  I thought php could be used by almost any hosting (am I wrong?)

2.  If I have to use linux hosting for my php script to work then why would the redirect in my php script be working?

 

thanks,

 

nofx1728

Link to comment
Share on other sites

With mailing features Windows generally does not support it without an SMTP server. Linux comes with sendmail be default, where as with windows you would have to setup exchange or something along those lines. Which is why most hosting companies who have hosting on windows do not support the mail feature with windows because it is a pain in the ass to setup.

 

That is all they are trying to say.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.