Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Email form causing problems....please help!
Old 04-20-2006, 07:30 PM Email form causing problems....please help!
Junior Talker

Posts: 2
Trades: 0
I have created a form and want it emailed to me upon submission. I have tried it in a file that contains form and php for email and it works but sends 2 copies of the email, first one blank 2nd is proper.

I aslo broke it into 2 php files, one with form, other to format and send email. This one doesn't do anything. It does pass the contents of the field but does not send the email.

Here is the code set up for the 1st scenerio, I have only included the php code if anyone needs to see the rest which is just the form let me know.

<?
function checkOK($field)
{
if (eregi("\r",$field) || eregi("\n", $field)){
die ("Invaild Input");
}
}

$name=$_POST['name'];
checkOK($name);
$company=$_POST['company'];
checkOK($company);
$address=$_POST['address'];
checkOK($address);
$postal=$_POST['postal'];
checkOK($postal);
$telephone=$_POST['telephone'];
checkOK($telephone);
$fax=$_POST['fax'];
checkOK($fax);
$poo=$_POST['poo'];
checkOK($poo);
$destination=$_POST['destination'];
checkOK($destination);
$truckload=$_POST['truckload'];
checkOK($truckload);
$ltl=$_POST['ltl'];
checkOK($ltl);
$hazard=$_POST['hazard'];
checkOK($hazard);
$assisted=$_POST['assisted'];
checkOK($assisted);
$pallet=$_POST['pallet'];
checkOK($pallet);
$weight=$_POST['weight'];
checkOK($weight);
$description=$_POST['description'];
checkOK($description);
$equipment=$_POST['equipment'];
checkOK($equipment);
$comments=$_POST['comments'];
checkOK($comments);

$to="brent@atlanticautos.ca";
$message="$name has submitted a rate request.\n\n Details are listed below:

<b>Name:</b> $name
<b>Company:</b> $company
<b>Address:</b> $address
<b>Postal/Zip:</b> $postal
<b>Email:</b> $email
<b>Tel:</b> $telephone
<b>Fax:</b> $fax
<b>Origin:</b> $poo
<b>Destination:</b> $destination
<b>Truckload:</b> $truckload
<b>LTL:</b> $ltl
<b>Hazardous:</b> $hazard
<b>Driver Asst:</b> $assisted
<b>Palletized:</b> $pallet
<b>Weight:</b> $weight
<b>Description:</b> $description
<b>Equipment:</b> $equipment
<b>Comments:</b> $comments";

if(mail($to,"Rate Request",$message,"From: $email\n")){
echo "thanks!";
}else{
echo "there was a problem";
}
?>


any help, suggestions, hints would be really appriceated. If anyone needs more info on this let me know.

tia
Napanguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-21-2006, 02:06 AM Re: Email form causing problems....please help!
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Maybe it's a little late and my eyes aren't great at the moment, but what you have here looks like it should work fine and just send the email once. Is it possible that in the other page the form itself gets submitted twice, once without any values being passed and a second time with everything being passed?
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 04-24-2006, 08:14 AM Re: Email form causing problems....please help!
Junior Talker

Posts: 2
Trades: 0
for some reason that i just can't figure out it is doing exactly what you said. As soon as i click submit it sends a blank email, then one with the field values. I even tried to have it go to a different page on submit with the email part there but then it doesn't even send.

if i put my code on a second page is there a command that will run the php script on load?
Napanguy is offline
Reply With Quote
View Public Profile
 
Old 04-24-2006, 12:34 PM Re: Email form causing problems....please help!
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
You shouldn't need to do anything special to get your code to run if you put it on a second page. When some requests the new page it will be run through the PHP engine to parse the code before the page is sent to a browser.

Though I have placed all my php for a form on the same page as the form, I typically send the information from the form to a thankyou page which contains all the php code and instructions for mailing the form results.

Is everything you have now on one page? And could you also post the rest of the code for the page? I get the feeling the problem you're having isn't in the code you posted above, but somewhere else on the page.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to Email form causing problems....please help!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22770 seconds with 12 queries