wrathican Posted August 9, 2007 Share Posted August 9, 2007 i made a function that sends an email, but i get this error when i test it: Warning: Missing argument 16 for sendbooking() in /home/fhlinux179/l/ls12style.co.uk/user/htdocs/CycleYorkshire/booking.php on line 100 line 100 is the start of creating my function. this is my function: function sendbooking($name, $email, $house, $street, $town, $postcode, $home, $mobile, $tour, $price, $type, $day, $month, $year, $experience, $health, ) { if (($type == 'course') && ($tour == 'INTERMEDIATE')) { $sendto = "intermediatecourses@cycleyorkshire.co.uk"; } elseif (($type == 'course') && ($tour == 'BEGGINNER')) { $sendto = "begginercourses@cycleyorkshire.co.uk"; }elseif ($type == 'tour') { $sendto = "tours@cycleyorkshire.co.uk"; } $subject = "Course/Tour Booking"; $headers = "From: " . $_POST['name']; $headers .= "<" . $_POST['email'] . ">\r\n"; $headers .= "Reply To: " . $_POST['email'] . "\r\n"; $headers .= "Return-Path: " . $_POST['email']; //this is gets the name of the tour instead of id $tour = $_POST['tour']; $query = "SELECT * FROM cy_list WHERE li_id='" . $tour . "'"; $result = mysql_query($query); while($row = mysql_fetch_array($result,MYSQL_NUM)) { $tourn = $row[2]; } //starts collecting the form vars. $type = $_POST['type']; $name = $_POST['name']; $email = $_POST['email']; $house = $_POST['house']; $street = $_POST['street']; $town = $_POST['town']; $postcode = $_POST['postcode']; $home = $_POST['home']; $mobile = $_POST['mobile']; $price = $_POST['price']; $day = $_POST['day']; $month = $_POST['month']; $year = $_POST['year']; $date = $day . "/" . $month . "/" . $year; $experience = $_POST['experience']; $health = $_POST['health']; //put form vars into one variable $booking = "\nName: " . $name . "\n"; $booking .= "E-Mail: " . $email . "\n"; $booking .= "House no/name: " . $house . "\n"; $booking .= "Street: " . $street . "\n"; $booking .= "Town: " . $town . "\n"; $booking .= "Postcode: " . $postcode . "\n"; $booking .= "Home No: " . $home . "\n"; $booking .= "Mobile: " . $mobile . "\n"; $booking .= "Tour: " . $tourn . "\n"; $booking .= "Prices: " . $price . "\n"; $booking .= "Date: " . $date . "\n"; $booking .= "Experience: " . $experience . "\n"; $booking .= "Health: " . $health . "\n"; //$body is whole email message sent to the user/owner $body = "There has been a new request for a booking:" . $booking; if (mail($sendto, $subject, $body, $headers)) { $sendto = $_POST['email']; $subject = "CycleYorkshire.co.uk E-Mail"; $headers = "From: Iain Johnson"; $headers .= "<iain@cycleyorkshire.co.uk>\r\n"; $headers .= "Reply To: iain@cycleyorkshire.co.uk\r\n"; $headers .= "Return-Path: iain@cycleyorkshire.co.uk"; $body = "Thank you for your booking. Here is a copy of the booking you have made: " . $booking; mail($sendto, $subject, $body, $headers); echo "Thank you for your booking. You will receive a copy of your booking shortly. Please do not forget to check you \'Junk\' folder as sometimes these emails can be thought of as spam."; } else { echo "I\'m sorry. There seems to be a problem. Please go <a href=\'/booking.php\'>back</a> and try again."; } } Quote Link to comment https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/ Share on other sites More sharing options...
jitesh Posted August 9, 2007 Share Posted August 9, 2007 function sendbooking($name, $email, $house, $street, $town, $postcode, $home, $mobile, $tour, $price, $type, $day, $month, $year, $experience, $health, "" ) or function sendbooking($name, $email, $house, $street, $town, $postcode, $home, $mobile, $tour, $price, $type, $day, $month, $year, $experience, $health) Quote Link to comment https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/#findComment-319291 Share on other sites More sharing options...
wrathican Posted August 9, 2007 Author Share Posted August 9, 2007 hmm nope i still get the same error thanks for the reply! the function did work before i added this part todecided which email address to send the email to: if (($type == 'course') && ($tour == 'INTERMEDIATE')) { $sendto = "intermediatecourses@cycleyorkshire.co.uk"; } elseif (($type == 'course') && ($tour == 'BEGGINNER')) { $sendto = "begginercourses@cycleyorkshire.co.uk"; }elseif ($type == 'tour') { $sendto = "tours@cycleyorkshire.co.uk"; } Quote Link to comment https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/#findComment-319295 Share on other sites More sharing options...
jitesh Posted August 9, 2007 Share Posted August 9, 2007 Above if else code is ok. Quote Link to comment https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/#findComment-319302 Share on other sites More sharing options...
wrathican Posted August 9, 2007 Author Share Posted August 9, 2007 maybe if i understand the error more i might be able to figure it out? i just tested it on my local machine but i commented the main bulk of the function out and added an echo $sendto; to see if it was determining the email address. i got this error: Warning: Missing argument 16 for sendbooking(), called in F:\wamp\www\CycleYorkshire\booking.php on line 182 and defined in F:\wamp\www\CycleYorkshire\booking.php on line 100 and my line 182 is this : sendbooking($_POST['name'],$_POST['email'],$_POST['house'],$_POST['street'],$_POST['town'],$_POST['postcode'],$_POST['home'],$_POST['mobile'],$_POST['tour'],$_POST['price'],$_POST['day'],$_POST['month'],$_POST['year'],$_POST['experience'],$_POST['health']); Quote Link to comment https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/#findComment-319341 Share on other sites More sharing options...
wrathican Posted August 9, 2007 Author Share Posted August 9, 2007 i thought i would use this thread to indicate the new problem i am facing. its within the same function and Quote Link to comment https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/#findComment-319381 Share on other sites More sharing options...
wrathican Posted August 9, 2007 Author Share Posted August 9, 2007 i thought i would use this thread to indicate the new problem i am facing. its within the same function and when i print the $sendto variable it comes up blank.. can i pirnt variables inside an if statement outside of it? if not how do i do this? Quote Link to comment https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/#findComment-319397 Share on other sites More sharing options...
wrathican Posted August 9, 2007 Author Share Posted August 9, 2007 bump Quote Link to comment https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/#findComment-319558 Share on other sites More sharing options...
jitesh Posted August 10, 2007 Share Posted August 10, 2007 Check how many argument you have in function implementation and how many arguments you have mention in function call. Quote Link to comment https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/#findComment-320040 Share on other sites More sharing options...
wrathican Posted August 10, 2007 Author Share Posted August 10, 2007 the fucntion works now, i found the missing variable, but i want to know whether this should work: if (($type == 'course') && ($tour == 'INTERMEDIATE')) { $sendto = "intermediatecourses@cycleyorkshire.co.uk"; } elseif (($type == 'course') && ($tour == 'BEGGINNER')) { $sendto = "begginercourses@cycleyorkshire.co.uk"; }elseif ($type == 'tour') { $sendto = "tours@cycleyorkshire.co.uk"; } echo $sendto; Quote Link to comment https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/#findComment-320179 Share on other sites More sharing options...
jitesh Posted August 10, 2007 Share Posted August 10, 2007 if (($type == 'course') && ($tour == 'INTERMEDIATE')) { $sendto = "intermediatecourses@cycleyorkshire.co.uk"; } elseif (($type == 'course') && ($tour == 'BEGGINNER')) { $sendto = "begginercourses@cycleyorkshire.co.uk"; }elseif ($type == 'tour') { $sendto = "tours@cycleyorkshire.co.uk"; }else{ $sendto = "Not Found"; } echo $sendto; Quote Link to comment https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/#findComment-320180 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.