Jump to content

Recommended Posts

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.";
}
}

Link to comment
https://forums.phpfreaks.com/topic/64067-solved-mail-function-error/
Share on other sites

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)

 

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";
}

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']);

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?

 

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;

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;

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.