SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP contact form - upload not working!

    Hi guys,

    I have a PHP contact form where people can apply for a vacancy online.

    I think I've pretty much got it working but a couple of things don't work as I'd like...

    1. If you don't fill in any of the compulsary fields the form is returned with a 'warning' message but doesn't keep any of the existing data. I'd like the existing data that the user has filled in to still be there.

    2. The file upload doesn't work. I pretty much copy and pasted the 'upload' script from an older form script I used to use. It worked with that form but I obviously haven't done something right somewhere down the line!

    If anyone could take a look at my code and see if they can see what needs changing to get the above working it would be very much appreciated.

    Thank you very much and I hope to hear from you.

    Here's the PHP page's code:



    Code:
    <?php
    
    if (array_key_exists('submit', $_POST)) {
        $position = $_POST['position'];
        $arrive = $_POST['arrive'];
        $nationality = $_POST['nationality'];
        $right = $_POST['right'];
        $country = $_POST['country'];
        $continue = $_POST['continue'];
        $restignes = $_POST['restignes'];
        $resvaldisere = $_POST['resvaldisere'];
        $reslesarcs = $_POST['reslesarcs'];
        $reslapagne = $_POST['reslapagne'];
        $resmeribel = $_POST['resmeribel'];
        $resvalthorens = $_POST['resvalthorens'];
        $parttime = $_POST['parttime'];
        $depart = $_POST['depart'];
        $name = $_POST['name'];
        $email = $_POST['email'];
        $telephone = $_POST['telephone'];
    
    if (empty($position)) {
    $warning['position'] = "Please type the title of the vacancy you are applying for";
    }
    
    if (empty($nationality)) {
    $warning['nationality'] = "Please select your nationality";
    }
    
    if (empty($country)) {
    $warning['country'] = "Please select which country you are currently living in";
    }
    
    if (empty($continue)) {
    $warning['continue'] = "Please select Yes or No";
    }
    
    if (empty($parttime)) {
    $warning['parttime'] = "Please confirm you understand";
    }
    
    if (empty($name)) {
    $warning['name'] = "Please provide your name";
    }
    
    if (empty($email)) {
    $warning['email'] = "Please provide your email address";
    }
    
    if (empty($telephone)) {
    $warning['telephone'] = "Please provide your contact telephone number";
    }
    
    $to = "me@myemail.com";
    $subject = "Recruitment Application";
    
    $message = $headers;
    $message .= "Name: " . $_POST["name"] . "\r\n";
    $message .= "E-mail: " . $_POST["email"] . "\r\n";
    
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    $headers .= 'From: My Website <info@mywebsite.com>' . "\r\n";
    
    
    
    $message= "
    
    <table cellspacing='0' cellpadding='8' border='0' width='500'>
    <tr>
    <td colspan='2'></td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td width='164' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Job Title:</strong></td>
    <td width='304' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$position."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td width='164' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Nationality:</strong></td>
    <td width='304' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$nationality."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td width='164' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Country of residence:</strong></td>
    <td width='304' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$country."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td width='164' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>If non-European do you have the right to work in the UK and Europe?:</strong></td>
    <td width='304' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$right."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td width='164' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Will you continue living in this country until the start of the winter season (Dec 2013):</strong></td>
    <td width='304' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$continue."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td width='164' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Resort accommodation</strong></td>
    <td width='304' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$restignes."<br />".$resvaldisere."<br />".$reslesarcs."<br />".$reslapagne."<br />".$resmeribel."<br />".$resvalthorens."<br /></td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td width='164' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>This is a part time role, please confirm you understand this.:</strong></td>
    <td width='304' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$parttime."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td width='164' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Date of arrival:</strong></td>
    <td width='304' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$arrive."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td width='164' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Date of departure:</strong></td>
    <td width='304' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$depart."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td width='164' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Name:</strong></td>
    <td width='304' style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$name."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>E-mail address:</strong></td>
    <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$email."</td>
    </tr>
    <tr bgcolor='#eeeeee'>
    <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'><strong>Telephone:</strong></td>
    <td style='font-family:Verdana, Arial; font-size:11px; color:#333333;'>".$telephone."</td>
    </tr>
    <tr><td colspan='2' style='padding: 0px;'></td></tr>
    </table>
    
    ";
     
    
    $url = stripslashes($_POST["url"]);
    if (!empty($url)) {
    header( 'Location: http://www.go-away-spam-robots.com' );
    exit();
    }
    
    if (!isset($warning)) {
    mail($to, $subject, $message, $headers);
    header( 'Location: http://www.mywebsite.com/thankyou.php' );
    }
    
    }
    
    
    
    
        // ATTACHMENT
    
        $strresume_name=$_FILES["strresume"]["name"];
        $strresume_type=$_FILES["strresume"]["type"];
        $strresume_size=$_FILES["strresume"]["size"];
        $strresume_temp=$_FILES["strresume"]["tmp_name"];
    
    
           
        if($strresume_type=="application/octet-stream" or $strresume_type=="text/plain" or $strresume_type=="application/msword" or $strresume_type=="application/vnd.openxmlformats-officedocument.wordprocessingml.document" or $strresume_type=="application/pdf")
        {
       
     
    
    
        // MAIL HEADERS with attachment
    
        $fp = fopen($strresume_temp, "rb");
        $file = fread($fp, $strresume_size);
    
        $file = chunk_split(base64_encode($file));
        $num = md5(time());
       
            //Normal headers
    
           $headers  .= "MIME-Version: 1.0\r\n";
           $headers  .= "Content-Type: multipart/mixed; ";
           $headers  .= "boundary=".$num."\r\n";
           $headers  .= "--$num\r\n";
    
            // This two steps to help avoid spam   
    
        $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n";
        $headers .= "X-Mailer: PHP v".phpversion()."\r\n";
    
            // Attachment headers
    
        $headers  .= "Content-Type:".$strresume_type." ";
           $headers  .= "name=\"".$strresume_name."\"r\n";
           $headers  .= "Content-Transfer-Encoding: base64\r\n";
           $headers  .= "Content-Disposition: attachment; ";
           $headers  .= "filename=\"".$strresume_name."\"\r\n\n";
           $headers  .= "".$file."\r\n";
           $headers  .= "--".$num."--";
         }
    
    
    
    
    
    
    ?>
    
    
    
    
    
    <form action="" method="post" name="contact" id="contact">
    
    <p>Job Title:* <?php if (isset($warning['position'])) { echo "<span class='warning'>".$warning['position']."</span>"; }?><br />
    <input name="position" <?php if (isset($warning['position'])) { echo "style='border: 1px solid #706f6e'"; } ?> type="text" class="ctextField" /></p>
    
    
    
    
    
    <p>Nationality:* <?php if (isset($warning['nationality'])) { echo "<span class='warning'>".$warning['nationality']."</span>"; }?><br />
    <select name="nationality" <?php if (isset($warning['nationality'])) { echo "style='border: 1px solid #706f6e'"; } ?> class="ctextField" />
      <option value="">-- select one --</option>
      <option value="Afghan">Afghan</option>
      <option value="Albanian">Albanian</option>
      <option value="Algerian">Algerian</option>
      <option value="American">American</option>
      <option value="Andorran">Andorran</option>
      <option value="Angolan">Angolan</option>
      <option value="Antiguans">Antiguans</option>
      <option value="Argentinean">Argentinean</option>
      <option value="Armenian">Armenian</option>
      <option value="Australian">Australian</option>
      <option value="Austrian">Austrian</option>
      <option value="Azerbaijani">Azerbaijani</option>
      <option value="Bahamian">Bahamian</option>
      <option value="Bahraini">Bahraini</option>
      <option value="Bangladeshi">Bangladeshi</option>
      <option value="Barbadian">Barbadian</option>
      <option value="Barbudans">Barbudans</option>
      <option value="Batswana">Batswana</option>
      <option value="Belarusian">Belarusian</option>
      <option value="Belgian">Belgian</option>
      <option value="Belizean">Belizean</option>
      <option value="Beninese">Beninese</option>
      <option value="Bhutanese">Bhutanese</option>
      <option value="Bolivian">Bolivian</option>
      <option value="Bosnian">Bosnian</option>
      <option value="Brazilian">Brazilian</option>
      <option value="British">British</option>
      <option value="Bruneian">Bruneian</option>
      <option value="Bulgarian">Bulgarian</option>
      <option value="Burkinabe">Burkinabe</option>
      <option value="Burmese">Burmese</option>
      <option value="Burundian">Burundian</option>
      <option value="Cambodian">Cambodian</option>
      <option value="Cameroonian">Cameroonian</option>
      <option value="Canadian">Canadian</option>
      <option value="Cape Verdean">Cape Verdean</option>
      <option value="Central African">Central African</option>
      <option value="Chadian">Chadian</option>
      <option value="Chilean">Chilean</option>
      <option value="Chinese">Chinese</option>
      <option value="Colombian">Colombian</option>
      <option value="Comoran">Comoran</option>
      <option value="Congolese">Congolese</option>
      <option value="Costa Rican">Costa Rican</option>
      <option value="Croatian">Croatian</option>
      <option value="Cuban">Cuban</option>
      <option value="Cypriot">Cypriot</option>
      <option value="Czech">Czech</option>
      <option value="Danish">Danish</option>
      <option value="Djibouti">Djibouti</option>
      <option value="Dominican">Dominican</option>
      <option value="Dutch">Dutch</option>
      <option value="East timorese">East Timorese</option>
      <option value="Ecuadorean">Ecuadorean</option>
      <option value="Egyptian">Egyptian</option>
      <option value="Emirian">Emirian</option>
      <option value="Equatorial guinean">Equatorial Guinean</option>
      <option value="Eritrean">Eritrean</option>
      <option value="Estonian">Estonian</option>
      <option value="Ethiopian">Ethiopian</option>
      <option value="Fijian">Fijian</option>
      <option value="Filipino">Filipino</option>
      <option value="Finnish">Finnish</option>
      <option value="French">French</option>
      <option value="Gabonese">Gabonese</option>
      <option value="Gambian">Gambian</option>
      <option value="Georgian">Georgian</option>
      <option value="German">German</option>
      <option value="Ghanaian">Ghanaian</option>
      <option value="Greek">Greek</option>
      <option value="Grenadian">Grenadian</option>
      <option value="Guatemalan">Guatemalan</option>
      <option value="Guinea-Bissauan">Guinea-Bissauan</option>
      <option value="Guinean">Guinean</option>
      <option value="Guyanese">Guyanese</option>
      <option value="Haitian">Haitian</option>
      <option value="Herzegovinian">Herzegovinian</option>
      <option value="Honduran">Honduran</option>
      <option value="Hungarian">Hungarian</option>
      <option value="Icelander">Icelander</option>
      <option value="Indian">Indian</option>
      <option value="Indonesian">Indonesian</option>
      <option value="Iranian">Iranian</option>
      <option value="Iraqi">Iraqi</option>
      <option value="Irish">Irish</option>
      <option value="Israeli">Israeli</option>
      <option value="Italian">Italian</option>
      <option value="Ivorian">Ivorian</option>
      <option value="Jamaican">Jamaican</option>
      <option value="Japanese">Japanese</option>
      <option value="Jordanian">Jordanian</option>
      <option value="Kazakhstani">Kazakhstani</option>
      <option value="Kenyan">Kenyan</option>
      <option value="Kittian and Nevisian">Kittian and Nevisian</option>
      <option value="Kuwaiti">Kuwaiti</option>
      <option value="Kyrgyz">Kyrgyz</option>
      <option value="Laotian">Laotian</option>
      <option value="Latvian">Latvian</option>
      <option value="Lebanese">Lebanese</option>
      <option value="Liberian">Liberian</option>
      <option value="Libyan">Libyan</option>
      <option value="Liechtensteiner">Liechtensteiner</option>
      <option value="Lithuanian">Lithuanian</option>
      <option value="Luxembourger">Luxembourger</option>
      <option value="Macedonian">Macedonian</option>
      <option value="Malagasy">Malagasy</option>
      <option value="Malawian">Malawian</option>
      <option value="Malaysian">Malaysian</option>
      <option value="Maldivan">Maldivan</option>
      <option value="Malian">Malian</option>
      <option value="Maltese">Maltese</option>
      <option value="Marshallese">Marshallese</option>
      <option value="Mauritanian">Mauritanian</option>
      <option value="Mauritian">Mauritian</option>
      <option value="Mexican">Mexican</option>
      <option value="Micronesian">Micronesian</option>
      <option value="Moldovan">Moldovan</option>
      <option value="Monacan">Monacan</option>
      <option value="Mongolian">Mongolian</option>
      <option value="Moroccan">Moroccan</option>
      <option value="Mosotho">Mosotho</option>
      <option value="Motswana">Motswana</option>
      <option value="Mozambican">Mozambican</option>
      <option value="Namibian">Namibian</option>
      <option value="Nauruan">Nauruan</option>
      <option value="Nepalese">Nepalese</option>
      <option value="New Zealander">New Zealander</option>
      <option value="Ni-Vanuatu">Ni-Vanuatu</option>
      <option value="Nicaraguan">Nicaraguan</option>
      <option value="Nigerien">Nigerien</option>
      <option value="North Korean">North Korean</option>
      <option value="Northern Irish">Northern Irish</option>
      <option value="Norwegian">Norwegian</option>
      <option value="Omani">Omani</option>
      <option value="Pakistani">Pakistani</option>
      <option value="Palauan">Palauan</option>
      <option value="Panamanian">Panamanian</option>
      <option value="Papua New Guinean">Papua New Guinean</option>
      <option value="Paraguayan">Paraguayan</option>
      <option value="Peruvian">Peruvian</option>
      <option value="Polish">Polish</option>
      <option value="Portuguese">Portuguese</option>
      <option value="Qatari">Qatari</option>
      <option value="Romanian">Romanian</option>
      <option value="Russian">Russian</option>
      <option value="Rwandan">Rwandan</option>
      <option value="Saint Lucian">Saint Lucian</option>
      <option value="Salvadoran">Salvadoran</option>
      <option value="Samoan">Samoan</option>
      <option value="San Marinese">San Marinese</option>
      <option value="Sao Tomean">Sao Tomean</option>
      <option value="Saudi">Saudi</option>
      <option value="Scottish">Scottish</option>
      <option value="Senegalese">Senegalese</option>
      <option value="Serbian">Serbian</option>
      <option value="Seychellois">Seychellois</option>
      <option value="Sierra Leonean">Sierra Leonean</option>
      <option value="Singaporean">Singaporean</option>
      <option value="Slovakian">Slovakian</option>
      <option value="Slovenian">Slovenian</option>
      <option value="Solomon Islander">Solomon Islander</option>
      <option value="Somali">Somali</option>
      <option value="South African">South African</option>
      <option value="South Korean">South Korean</option>
      <option value="Spanish">Spanish</option>
      <option value="Sri lankan">Sri Lankan</option>
      <option value="Sudanese">Sudanese</option>
      <option value="Surinamer">Surinamer</option>
      <option value="Swazi">Swazi</option>
      <option value="Swedish">Swedish</option>
      <option value="Swiss">Swiss</option>
      <option value="Syrian">Syrian</option>
      <option value="Taiwanese">Taiwanese</option>
      <option value="Tajik">Tajik</option>
      <option value="Tanzanian">Tanzanian</option>
      <option value="Thai">Thai</option>
      <option value="Togolese">Togolese</option>
      <option value="Tongan">Tongan</option>
      <option value="Trinidadian or Tobagonian">Trinidadian or Tobagonian</option>
      <option value="Tunisian">Tunisian</option>
      <option value="Turkish">Turkish</option>
      <option value="Tuvaluan">Tuvaluan</option>
      <option value="Ugandan">Ugandan</option>
      <option value="Ukrainian">Ukrainian</option>
      <option value="Uruguayan">Uruguayan</option>
      <option value="Uzbekistani">Uzbekistani</option>
      <option value="Venezuelan">Venezuelan</option>
      <option value="Vietnamese">Vietnamese</option>
      <option value="Welsh">Welsh</option>
      <option value="Yemenite">Yemenite</option>
      <option value="Zambian">Zambian</option>
      <option value="Zimbabwean">Zimbabwean</option>
    </select>
    </p>
    
    
    
    
    
    <p>Which country are you currently living in?* <?php if (isset($warning['country'])) { echo "<span class='warning'>".$warning['country']."</span>"; }?><br />
    <select name="country" <?php if (isset($warning['country'])) { echo "style='border: 1px solid #706f6e'"; } ?> class="ctextField" />
    <option value="">-- select one --</option>
    <option value="United Kingdom">United Kingdom</option>
    <option value="Afghanistan">Afghanistan</option>
    <option value="Africa">Africa</option>
    <option value="Albania">Albania</option>
    <option value="Algeria">Algeria</option>
    <option value="American Samoa">American Samoa</option>
    <option value="Andorra">Andorra</option>
    <option value="Angola">Angola</option>
    <option value="Anguilla">Anguilla</option>
    <option value="Antarctica">Antarctica</option>
    <option value="Antigua &amp; Barbuda">Antigua &amp; Barbuda</option>
    <option value="Antilles, Netherlands">Antilles, Netherlands</option>
    <option value="Arabia, Saudi">Arabia, Saudi</option>
    <option value="Argentina">Argentina</option>
    <option value="Armenia">Armenia</option>
    <option value="Aruba">Aruba</option>
    <option value="Australia">Australia</option>
    <option value="Austria">Austria</option>
    <option value="Azerbaijan">Azerbaijan</option>
    <option value="Bahamas, The">Bahamas, The</option>
    <option value="Bahrain">Bahrain</option>
    <option value="Bangladesh">Bangladesh</option>
    <option value="Barbados">Barbados</option>
    <option value="Belarus">Belarus</option>
    <option value="Belgium">Belgium</option>
    <option value="Belize">Belize</option>
    <option value="Benin">Benin</option>
    <option value="Bermuda">Bermuda</option>
    <option value="Bhutan">Bhutan</option>
    <option value="Bolivia">Bolivia</option>
    <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
    <option value="Botswana">Botswana</option>
    <option value="Bouvet Island">Bouvet Island</option>
    <option value="Brazil">Brazil</option>
    <option value="British Indian Ocean Territory">British Indian Ocean Territory</option>
    <option value="British Virgin Islands">British Virgin Islands</option>
    <option value="Brunei Darussalam">Brunei Darussalam</option>
    <option value="Bulgaria">Bulgaria</option>
    <option value="Burkina Faso">Burkina Faso</option>
    <option value="Burundi">Burundi</option>
    <option value="Cambodia">Cambodia</option>
    <option value="Cameroon">Cameroon</option>
    <option value="Canada">Canada</option>
    <option value="Cape Verde">Cape Verde</option>
    <option value="Cayman Islands">Cayman Islands</option>
    <option value="Central African Republic">Central African Republic</option>
    <option value="Chad">Chad</option>
    <option value="Chile">Chile</option>
    <option value="China">China</option>
    <option value="Christmas Island">Christmas Island</option>
    <option value="Cocos (Keeling) Islands">Cocos (Keeling) Islands</option>
    <option value="Colombia">Colombia</option>
    <option value="Comoros">Comoros</option>
    <option value="Congo">Congo</option>
    <option value="Congo, Democratic Rep. of the">Congo, Democratic Rep. of the</option>
    <option value="Cook Islands">Cook Islands</option>
    <option value="Cote D'Ivoire">Cote D'Ivoire</option>
    <option value="Croatia">Croatia</option>
    <option value="Cuba">Cuba</option>
    <option value="Cyprus">Cyprus</option>
    <option value="Czech Republic">Czech Republic</option>
    <option value="Denmark">Denmark</option>
    <option value="Djibouti">Djibouti</option>
    <option value="Dominica">Dominica</option>
    <option value="Dominican Republic">Dominican Republic</option>
    <option value="East Timor (Timor-Leste)">East Timor (Timor-Leste)</option>
    <option value="Ecuador">Ecuador</option>
    <option value="Egypt">Egypt</option>
    <option value="El Salvador">El Salvador</option>
    <option value="Equatorial Guinea">Equatorial Guinea</option>
    <option value="Eritrea">Eritrea</option>
    <option value="Estonia">Estonia</option>
    <option value="Ethiopia">Ethiopia</option>
    <option value="European Union">European Union</option>
    <option value="Falkland Islands (Malvinas)">Falkland Islands (Malvinas)</option>
    <option value="Faroe Islands">Faroe Islands</option>
    <option value="Fiji">Fiji</option>
    <option value="Finland">Finland</option>
    <option value="France">France</option>
    <option value="French Guiana">French Guiana</option>
    <option value="French Polynesia">French Polynesia</option>
    <option value="French Southern Territories - TF">French Southern Territories - TF</option>
    <option value="Gabon">Gabon</option>
    <option value="Gambia, The">Gambia, The</option>
    <option value="Georgia">Georgia</option>
    <option value="Germany">Germany</option>
    <option value="Ghana">Ghana</option>
    <option value="Gibraltar">Gibraltar</option>
    <option value="Greece">Greece</option>
    <option value="Greenland">Greenland</option>
    <option value="Grenada">Grenada</option>
    <option value="Guadeloupe">Guadeloupe</option>
    <option value="Guam">Guam</option>
    <option value="Guatemala">Guatemala</option>
    <option value="Guernsey and Alderney">Guernsey and Alderney</option>
    <option value="Guinea">Guinea</option>
    <option value="Guinea-Bissau">Guinea-Bissau</option>
    <option value="Guinea, Equatorial">Guinea, Equatorial</option>
    <option value="Guiana, French">Guiana, French</option>
    <option value="Guyana">Guyana</option>
    <option value="Haiti">Haiti</option>
    <option value="Heard and McDonald Islands">Heard and McDonald Islands</option>
    <option value="Holy See (Vatican City State)">Holy See (Vatican City State)</option>
    <option value="Holland (see Netherlands)">Holland (see Netherlands)</option>
    <option value="Honduras">Honduras</option>
    <option value="Hong Kong, China">Hong Kong, China</option>
    <option value="Hungary">Hungary</option>
    <option value="Iceland">Iceland</option>
    <option value="India">India</option>
    <option value="Indonesia">Indonesia</option>
    <option value="Iran, Islamic Republic of">Iran, Islamic Republic of</option>
    <option value="Iraq">Iraq</option>
    <option value="Ireland">Ireland</option>
    <option value="Ivory Coast">Ivory Coast</option>
    <option value="Italy">Italy</option>
    <option value="Jamaica">Jamaica</option>
    <option value="Japan">Japan</option>
    <option value="Jersey">Jersey</option>
    <option value="Jordan">Jordan</option>
    <option value="Kazakhstan">Kazakhstan</option>
    <option value="Kenya">Kenya</option>
    <option value="Kiribati">Kiribati</option>
    <option value="Korea, Demo. People's Rep. of">Korea, Demo. People's Rep. of</option>
    <option value="Korea, (South) Republic of">Korea, (South) Republic of</option>
    <option value="Kuwait">Kuwait</option>
    <option value="Kyrgyzstan">Kyrgyzstan</option>
    <option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option>
    <option value="Latvia">Latvia</option>
    <option value="Lebanon">Lebanon</option>
    <option value="Lesotho">Lesotho</option>
    <option value="Liberia">Liberia</option>
    <option value="Libyan Arab Jamahiriya">Libyan Arab Jamahiriya</option>
    <option value="Liechtenstein">Liechtenstein</option>
    <option value="Lithuania">Lithuania</option>
    <option value="Luxembourg">Luxembourg</option>
    <option value="Macao, (China)">Macao, (China)</option>
    <option value="Macedonia, TFYR">Macedonia, TFYR</option>
    <option value="Madagascar">Madagascar</option>
    <option value="Malawi">Malawi</option>
    <option value="Malaysia">Malaysia</option>
    <option value="Maldives">Maldives</option>
    <option value="Mali">Mali</option>
    <option value="Malta">Malta</option>
    <option value="Man, Isle of">Man, Isle of</option>
    <option value="Marshall Islands">Marshall Islands</option>
    <option value="Martinique">Martinique</option>
    <option value="Mauritania">Mauritania</option>
    <option value="Mauritius">Mauritius</option>
    <option value="Mayotte">Mayotte</option>
    <option value="Mexico">Mexico</option>
    <option value="Micronesia, Federated States of">Micronesia, Federated States of</option>
    <option value="Moldova, Republic of">Moldova, Republic of</option>
    <option value="Monaco">Monaco</option>
    <option value="Mongolia">Mongolia</option>
    <option value="Montenegro">Montenegro</option>
    <option value="Montserrat">Montserrat</option>
    <option value="Morocco">Morocco</option>
    <option value="Mozambique">Mozambique</option>
    <option value="Myanmar (ex-Burma)">Myanmar (ex-Burma)</option>
    <option value="Namibia">Namibia</option>
    <option value="Nauru">Nauru</option>
    <option value="Nepal">Nepal</option>
    <option value="Netherlands">Netherlands</option>
    <option value="Netherlands Antilles">Netherlands Antilles</option>
    <option value="New Caledonia">New Caledonia</option>
    <option value="New Zealand">New Zealand</option>
    <option value="Nicaragua">Nicaragua</option>
    <option value="Niger">Niger</option>
    <option value="Nigeria">Nigeria</option>
    <option value="Niue">Niue</option>
    <option value="Norfolk Island">Norfolk Island</option>
    <option value="Northern Mariana Islands">Northern Mariana Islands</option>
    <option value="Norway">Norway</option>
    <option value="Oman">Oman</option>
    <option value="Pakistan">Pakistan</option>
    <option value="Palau">Palau</option>
    <option value="Palestinian Territory">Palestinian Territory</option>
    <option value="Panama">Panama</option>
    <option value="Papua New Guinea">Papua New Guinea</option>
    <option value="Paraguay">Paraguay</option>
    <option value="Peru">Peru</option>
    <option value="Philippines">Philippines</option>
    <option value="Pitcairn Island">Pitcairn Island</option>
    <option value="Poland">Poland</option>
    <option value="Portugal">Portugal</option>
    <option value="Puerto Rico">Puerto Rico</option>
    <option value="Qatar">Qatar</option>
    <option value="Reunion">Reunion</option>
    <option value="Romania">Romania</option>
    <option value="Russia (Russian Federation)">Russia (Russian Federation)</option>
    <option value="Rwanda">Rwanda</option>
    <option value="Sahara">Sahara</option>
    <option value="Saint Helena">Saint Helena</option>
    <option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option>
    <option value="Saint Lucia">Saint Lucia</option>
    <option value="Saint Pierre and Miquelon">Saint Pierre and Miquelon</option>
    <option value="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option>
    <option value="Samoa">Samoa</option>
    <option value="San Marino">San Marino</option>
    <option value="Sao Tome and Principe">Sao Tome and Principe</option>
    <option value="Saudi Arabia">Saudi Arabia</option>
    <option value="Senegal">Senegal</option>
    <option value="Serbia">Serbia</option>
    <option value="Seychelles">Seychelles</option>
    <option value="Sierra Leone">Sierra Leone</option>
    <option value="Singapore">Singapore</option>
    <option value="Slovakia">Slovakia</option>
    <option value="Slovenia">Slovenia</option>
    <option value="Solomon Islands">Solomon Islands</option>
    <option value="Somalia">Somalia</option>
    <option value="South Africa">South Africa</option>
    <option value="S. Georgia and S. Sandwich Is.">S. Georgia and S. Sandwich Is.</option>
    <option value="Spain">Spain</option>
    <option value="Sri Lanka">Sri Lanka</option>
    <option value="Sudan">Sudan</option>
    <option value="Suriname">Suriname</option>
    <option value="Svalbard and Jan Mayen Islands">Svalbard and Jan Mayen Islands</option>
    <option value="Swaziland">Swaziland</option>
    <option value="Sweden">Sweden</option>
    <option value="Switzerland">Switzerland</option>
    <option value="Syrian Arab Republic">Syrian Arab Republic</option>
    <option value="Taiwan">Taiwan</option>
    <option value="Tajikistan">Tajikistan</option>
    <option value="Tanzania, United Republic of ">Tanzania, United Republic of </option>
    <option value="Thailand">Thailand</option>
    <option value="Timor-Leste (East Timor)">Timor-Leste (East Timor)</option>
    <option value="Togo">Togo</option>
    <option value="Tokelau">Tokelau</option>
    <option value="Tonga">Tonga</option>
    <option value="Trinidad & Tobago">Trinidad & Tobago</option>
    <option value="Tunisia">Tunisia</option>
    <option value="Turkey">Turkey</option>
    <option value="Turkmenistan">Turkmenistan</option>
    <option value="Turks and Caicos Islands">Turks and Caicos Islands</option>
    <option value="Tuvalu">Tuvalu</option>
    <option value="Uganda">Uganda</option>
    <option value="Ukraine">Ukraine</option>
    <option value="United Arab Emirates">United Arab Emirates</option>
    <option value="United Kingdom">United Kingdom</option>
    <option value="United States of America">United States of America</option>
    <option value="US Minor Outlying Islands">US Minor Outlying Islands</option>
    <option value="Uruguay">Uruguay</option>
    <option value="Uzbekistan">Uzbekistan</option>
    <option value="Vanuatu">Vanuatu</option>
    <option value="Vatican City State (Holy See)">Vatican City State (Holy See)</option>
    <option value="Venezuela">Venezuela</option>
    <option value="Viet Nam">Viet Nam</option>
    <option value="Virgin Islands, British">Virgin Islands, British</option>
    <option value="Virgin Islands, U.S.">Virgin Islands, U.S.</option>
    <option value="Wallis and Futuna">Wallis and Futuna</option>
    <option value="Western Sahara">Western Sahara</option>
    <option value="Yemen">Yemen</option>
    <option value="Zambia">Zambia</option>
    <option value="Zimbabwe">Zimbabwe</option>
    </select>
    </p>
    
    
    
    <label class="radio" for="checkRight">If non-European, do you have the right to work in the UK and Europe?</label><br />
    <input class="radio" type="radio" name="right" value="Yes" /> Yes
    <input class="radio" type="radio" name="right" value="No" /> No
    <input class="radio" type="radio" name="right" value="N/A" /> Not applicable
    
    
    
    <p>Will you continue living in this country until the start of the winter season (Dec 2013) <?php if (isset($warning['continue'])) { echo "<span class='warning'>".$warning['continue']."</span>"; }?><br />
    <select name="continue" <?php if (isset($warning['continue'])) { echo "style='border: 1px solid #706f6e'"; } ?> size="1" class="ctextField">
    <option value="">-- select one --</option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
    </select>
    </p>
    
    
    
    
    
    <p>
    Resort accommodation:<br />
    
    Resort 1 <input name="res1" type="checkbox" value="Resort 1" />
    Resort 2 <input name="res2" type="checkbox" value="Resort 2" />
    Resort 3 <input name="res3" type="checkbox" value="Resort 3" />
    Resort 4 <input name="res4" type="checkbox" value="Resort 4" />
    Resort 5 <input name="res5" type="checkbox" value="Resort 5" />
    Resort 6 <input name="res6" type="checkbox" value="Resort 6" />
    
    </p>
    
    
    
    
    
    <p>
    This is a part time role, please confirm you understand this:* <input type="checkbox" name="parttime" <?php if (isset($warning['parttime'])) { echo "style='border: 1px solid #706f6e'"; } ?> value="Yes" /> <?php if (isset($warning['parttime'])) { echo "<span class='warning'>".$warning['parttime']."</span>"; }?>
    </p>
    
    
    
    
    
    
    <p>Date of arrival:
    <input name="arrive" id="datepick" /> 
    Date of departure:
    <input name="depart" id="datepick2" /></p>
    
    <script type="text/javascript" src="assets/scripts/datepickr/datepickr.js"></script>
    <link href="assets/scripts/datepickr/datepickr.css" rel="stylesheet">
    
    <script type="text/javascript">
    new datepickr('datepick');
    			
    new datepickr('datepick2', {
    });
    </script>
    
    
    
    <p>Name:* <?php if (isset($warning['name'])) { echo "<span class='warning'>".$warning['name']."</span>"; }?><br />
    <input name="name" <?php if (isset($warning['name'])) { echo "style='border: 1px solid #706f6e'"; } ?> type="text" class="ctextField" /></p>
    
    
    
    <p>E-mail:* <?php if (isset($warning['email'])) { echo "<span class='warning'>".$warning['email']."</span>"; }?><br />
    <input name="email" <?php if (isset($warning['email'])) { echo "style='border: 1px solid #706f6e'"; } ?> type="text" class="ctextField" /></p>
    
    
    
    <p>Telephone:* <?php if (isset($warning['telephone'])) { echo "<span class='warning'>".$warning['telephone']."</span>"; }?><br />
    <input name="telephone" <?php if (isset($warning['telephone'])) { echo "style='border: 1px solid #706f6e'"; } ?> type="text" class="ctextField" /></p>
    
    <p>Upload your current CV (Word of PDF formats only):<br />
    <input type="file" name="strresume" class="textfield"></p>
    
    
    <p><input name="submit" value="Submit Enquiry" class="submitButton" type="submit" /><div style="visibility:hidden; width:1px; height:1px"><input name="url" type="text" size="45" id="url" /></div></p>
    
    </form>

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    88
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Try adding value clauses to your input if you want the previously entered values to show up on a re-display. Ex.: value="$position".

    Plus - try using css instead of ALL THOSE STYLE tags on every single element. You must have copied all this code, cause no one in their right mind would type in all that same stuff over and over again.
    Plus - try and organize this code. It's pretty hard to understand when you have all this js,php,html code intermingled.

  3. #3
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,256
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ginerjm View Post
    Try adding value clauses to your input if you want the previously entered values to show up on a re-display. Ex.: value="$position".
    To do this with your dropdown lists, you can put all your options in an array, and loop over it to build your option tags. This lets you add the selected attribute to the relevant option:
    PHP Code:
    <?php
    $nationalities 
    = array(
        
    'Afghan',
        
    'Albanian',
        ...
        
    'Zambian',
        
    'Zimbabwean'
    );
    ?>
    <p>Nationality:* <?php if (isset($warning['nationality'])) { echo "<span class='warning'>".$warning['nationality']."</span>"; }?><br />
    <select name="nationality" <?php if (isset($warning['nationality'])) { echo "style='border: 1px solid #706f6e'"; } ?> class="ctextField" />
        <option value="">-- select one --</option>
        <?php foreach($nationalities as $value) {
            
    $selected = (isset($nationality) && $nationality == $value) ? 'selected' '';
            echo 
    "<option value='$value$selected>$value</option>";
        } 
    ?>
    </select>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •