-2

I'm attempting to make an enquiry form on my site send an email regarding a booking. But I cannot work out my mistake in the PHP, very much a beginner to PHP so don't know where I went wrong.

I receive no email when testing the form on server.

<?php 

$firstname = $_post['firstname'];
$lastname = $_post['lastname'];
$bandname = $_post['bandname'];
$email = $_post['email'];
$phoneno = $_post['phoneno'];
$startday = $_post['start_day'];
$startmonth = $_post['start_month'];
$starthour = $_post['start_hour'];
$startminute = $_post['start_minute'];
$endday = $_post['end_day'];
$endmonth = $_post['end_month'];
$endhour = $_post['end_hour'];
$endminute = $_post['end_minute'];
$extras = $_post['extras'];

$to = "some@emailaddress.com";
$subject = "New Message";

mail ($to, $subject, $firstname . $lastname, $bandname, $email, $phoneno, $start_day . $start_month, $start_hour . $start_minute, $end_day . $end_month, $end_hour . $end_minute, $extras);
?>

HTML of my form :

                       <form action="form.php" class="appnitro" id="form_1062945" method="post" name="form_1062945" style="display: inline-block;">
                            <div class="form_description medium-8 small-10 columns medium-centered small-centered" style="margin-bottom:45px">
                                <p>
                                    Please complete the form below to send us details of the booking you would like to make, we will then get back to you within one business day to confirm your booking.
                                </p>
                            </div>

                            <ul>
                                <li class="small-6 columns" id="li_1">
                                    <label class="description" for="element_1">First Name</label>
                                    <div>
                                        <input class="element text medium" id="element_1" maxlength="255" name="firstname" type="text" value="">
                                    </div>
                                </li>

                                <li class="small-6 columns" id="li_2">
                                    <label class="description" for="element_2">Last Name</label>
                                    <div>
                                        <input class="element text medium" id="element_2" maxlength="255" name="lastname" type="text" value="">
                                    </div>
                                </li>

                                <li class="small-6 columns" id="li_3">
                                    <label class="description" for="element_3">Company/band/artist</label>
                                    <div>
                                        <input class="element text medium" id="element_3" maxlength="255" name="bandname" type="text" value="">
                                    </div>
                                </li>

                                <li class="small-6 columns" id="li_8">
                                    <label class="description" for="element_8">Email</label>
                                    <div>
                                        <input class="element text medium" id="element_8" maxlength="255" name="email" type="text" value="">
                                    </div>
                                </li>

                                <li class="small-6 end columns" id="li_4">
                                    <label class="description" for="element_4">Phone number</label>
                                    <div>
                                        <input class="element text medium" id="element_4" maxlength="255" name="phoneno" type="text" value="">
                                    </div>
                                </li>

                                <div class="row">
                                    <div class="small-12 columns">

                                        <li class="small-12 columns text-left" id="li_11">
                                            <label class="description" for="element_11_1">Which space(s) are you interested in?</label>

                                            <div class="line-boxes">
                                                <span>
                                                    <input class="element checkbox" id="element_11_1" name="studio_1" type="checkbox" value="1"> 
                                                    <label class="choice" for="element_11_1">Studio 1</label>
                                                </span>
                                            </div>

                                            <div class="line-boxes">
                                                <span><input class="element checkbox" id="element_11_2" name="studio_2" type="checkbox" value="1"> 
                                                    <label class="choice" for="element_11_2" style="margin-bottom:20px">Studio 2</label>
                                                </span>
                                            </div>

                                        </li>

                                    </div>
                                </div>

                                <li class="small-12 medium-6 columns lose-pad" id="li_6">

                                    <label class="description" for="element_6_1">Start Date</label>

                                    <span class="small-6 columns">
                                        <input class="element text" id="element_6_1" maxlength="2" name="start_day" size="2" type="text" value=""> 
                                        <label for="element_6_1" style="font-size:10px">DD</label>
                                    </span>

                                    <span class="small-6 columns">
                                        <input class="element text" id="element_6_2" maxlength="2" name="start_month" size="2" type="text" value=""> 
                                        <label for="element_6_2" style="font-size:10px">MM</label>
                                    </span>

                                </li>

                                <li class="medium-6 small-12 columns lose-pad" id="li_5">

                                    <label class="description" for="element_5_1">Start Time</label> 

                                    <span class="small-6 columns">
                                        <input class="element text" id="element_5_1" maxlength="2" name="start_hour" size="2" type="text" value=""> 
                                        <label for="element_5_1" style="font-size:10px">HH</label>
                                    </span> 

                                    <span class="small-6 columns">
                                        <input class="element text" id="element_5_2" maxlength="2" name="start_minute" size="2" type="text" value=""> 
                                        <label for="element_5_2" style="font-size:10px">MM</label>
                                    </span>

                                </li>

                                <li class="small-12 medium-6 columns lose-pad" id="li_9">

                                    <label class="description" for="element_9_2">End Date</label> 

                                    <span class="small-6 columns">
                                        <input class="element text" id="element_9_2" maxlength="2" name="end_day" size="2" type="text" value=""> 
                                        <label for="element_9_2" style="font-size:10px">DD</label>
                                    </span> 

                                    <span class="small-6 columns">

                                        <input class="element text" id="element_9_1" maxlength="2" name="end_month" size="2" type="text" value=""> 
                                        <label for="element_9_1" style="font-size:10px">MM</label>
                                    </span> 

                                </li>

                                <li class="medium-6 small-12 columns lose-pad" id="li_7">

                                    <label class="description" for="element_7_1">End Time</label> <span class="small-6 columns">

                                    <input class="element text" id="element_7_1" maxlength="2" name="end_hour" size="2" type="text" value=""> 
                                    <label for="element_7_1" style="font-size:10px">HH</label>
                                    </span> 

                                    <span class="small-6 columns">
                                        <input class="element text" id="element_7_2" maxlength="2" name="end_minute" size="2" type="text" value=""> 
                                        <label for="element_7_2" style="font-size:10px">MM</label>
                                    </span>

                                </li>

                                <li class="small-12 columns text-left" id="li_12">

                                    <label class="description" for="element_12_1" style="margin-top:20px">Do you require or interested in any of the following additional services?</label> 
                                    <div class="line-boxes" style="margin-top:20px">
                                        <span><input class="element checkbox" id="element_12_1" name="console_wedges" type="checkbox" value="1"> 
                                            <label class="choice" for="element_12_1">House monitor console and wedges?</label>
                                        </span>
                                    </div>

                                    <div class="line-boxes">
                                        <span>
                                            <input class="element checkbox" id="element_12_2" name="iem" type="checkbox" value="1"> 
                                            <label class="choice" for="element_12_2">IEM System rental?</label>
                                        </span>
                                    </div>

                                    <div class="line-boxes">
                                        <span>
                                            <input class="element checkbox" id="element_12_3" name="chairs" type="checkbox" value="1"> 
                                            <label class="choice" for="element_12_3">Chairs?</label>
                                        </span>
                                    </div>

                                    <div class="line-boxes">
                                        <span>
                                            <input class="element checkbox" id="element_12_4" name="stools" type="checkbox" value="1"> 
                                            <label class="choice" for="element_12_4">Stools?</label>
                                        </span>
                                    </div>

                                    <div class="line-boxes">
                                        <span>
                                            <input class="element checkbox" id="element_12_5" name="backline" type="checkbox" value="1"> 
                                            <label class="choice" for="element_12_5">Backline rental?</label>
                                        </span>
                                    </div>

                                    <div class="line-boxes">
                                        <span>
                                            <input class="element checkbox" id="element_12_6" name="transport" type="checkbox" value="1"> 
                                            <label class="choice" for="element_12_6" style="margin-bottom:30px">Transport of equipment to or from Ritz</label>                                              </span>
                                    </div>

                                </li>

                                <li class="small-12 columns" id="li_10">

                                    <label class="description" for="element_10">Anything else we should know to help assist with your booking?</label>

                                    <div>
                                        <textarea class="element textarea small" id="element_10" name="extras"></textarea>
                                    </div>
                                </li>

                                <li class="buttons small-6 columns small-centered">
                                    <input name="form_id" type="hidden" value="1062945">
                                    <input class="button_text" id="saveForm" name="submit" type="submit" value="Submit">
                                </li>

                            </ul>
                        </form>
Mike Smith
  • 107
  • 1
  • 1
  • 11

1 Answers1

3

Firstly, all your $_post are incorrect.

That is a superglobal and must read as $_POST.

Then you're injecting too many parameters in your mail() function.

Please read the manual:

Your server may not be setup to catch and display/log errors/notices/warnings.

Having used error reporting, would have thrown you many notices.

Add error reporting to the top of your file(s) which will help find errors.

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

// rest of your code

Sidenote: Displaying errors should only be done in staging, and never production.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141