Need help with PHP form with checkboxes, radio buttons and file attachment

Hi guys,
I'm having a nightmare with this PHP form where a user can fill it in, attach a doc/pdf and submit. After trying to sort it out with previous code I've used, I've stripped it out and think I should just start again in the hope you geniuses can help!
Here is the HTML of contact.php:
<form action="" method="post" name="contact" id="contact">
    <p>Job Title:*<br />
    <input name="position" type="text" /></p>
    <p>Nationality:*<br />
    <select name="nationality">
      <option value="">-- select one --</option>
      <option value="Afghan">Afghan</option>
      <option value="Albanian">Albanian</option>
      <option value="Algerian">Algerian</option>
      <option value="Zambian">Zambian</option>
      <option value="Zimbabwean">Zimbabwean</option>
    </select>
    </p>
    <p>Which country are you currently living in?*<br />
    <select name="country">
    <option value="">-- select one --</option>
    <option value="United Kingdom">United Kingdom</option>
    <option value="Afghanistan">Afghanistan</option>
    <option value="Africa">Africa</option>
    <option value="Zambia">Zambia</option>
    <option value="Zimbabwe">Zimbabwe</option>
    </select>
    </p>
    <label class="radio" for="checkRight">Yes/No question?</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>Yes/No question?<br />
    <select name="continue">
    <option value="">-- select one --</option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
    </select>
    </p>
    <p>Select your resorts:<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>Don't send form unless this is checked:* <input type="checkbox" name="parttime" value="Yes" /></p>
    <p>Date of arrival: <input name="arrive" id="datepick" /><br />
    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:*<br />
    <input name="name" type="text" /></p>
    <p>E-mail:*<br />
    <input name="email" type="text" /></p>
    <p>Telephone:*<br />
    <input name="telephone" type="text" class="ctextField" /></p>
    <p>Upload CV (Word of PDF formats only):<br />
    <input type="file" name="cv" 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>
By the way, the date boxes work so excuse the Javascript in there!
To prevent SPAM I've used a trick where there's a hidden URL field which must be left blank for the form to submit which you can see in the PHP.
Below is where I'm at with the PHP which is placed above the header of contact.php...
<?php
if (array_key_exists('submit', $_POST)) {
    $position = $_POST['position'];
    $arrive = $_POST['arrive'];
    $nationality = $_POST['nationality'];
    $parttime = $_POST['parttime'];
    $depart = $_POST['depart'];
    $name = $_POST['name'];
    $email = $_POST['email'];
    $telephone = $_POST['telephone'];
$to = "[email protected]";
$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 <[email protected]>' . "\r\n";
$message= "
$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.co.uk/sent.php' );
?>
I would like to make pretty much all the field compulsory so if a field is left empty (other than the hidden URL field), a warning message is displayed next to that field.
Also I would like the file upload field to attach to the email that is sent to me and have the results come through to me in a table format.
Can anyone help me get my form working?
Thank you and I hope to hear from you!
SM

Hi Nancy,
Great stuff, thank you for the reply.
I've managed to get the Formm@iler working and running as I need it to.
The only thing I'm struggling with is when the user clicks submit, they are taken to a page of whatever results the form returned but it is just a white background with Times New Roman text.
How can I have it so the user is taken to the form results in the websites' page layout?
I tried sending them to a generic 'thank you' page by adding the following code but it just took them there whatever the results of the form so that's no good...! I have a feeling it's a bit more complicated than that...
header( 'Location: http://www.nofussbus.co.uk/test/sent.php' );
Thank you for your help!

Similar Messages

  • Please help! How can I validate Radio Buttons and List Menu with PHP.

    Hello everyone, I have been learning PHP step by step and
    making little projects.
    The point is I find it easy to learn by doing "practical
    projects."
    I have been reading the David Powers's Book on PHP Solutions
    and it's really great, however there is nothing mentioned regarding
    Validating Radio buttons. I know the book cannot cover every aspect
    of PHP and maybe someone in here can help.
    I have been learning how to process HTML forms with PHP.
    The problem is every book or tutorial I have read or
    encountered fall short on validation.
    I'm wondering how I can learn to validate Radio Buttons and
    Select List Menu.
    I have managed to create validation for all other fields but
    have no clue as to how I can get validation for Radio Buttons and
    List Menu.
    I would also like an error message echoed when the user does
    not click a button or make a selection and try to submit the form.
    I would appreciate any help.
    Patrick

    It's not that default value is "None." In fact it's not. It
    will only be
    "none" when the form is submitted.
    Also if your submit button is names 'send' then
    $_POST['send'] will only be
    set if the form was submitted.
    Make sure you didn't hit the refresh button on your browser
    which usually
    reposts the information. Also make sure you did not reach the
    form from
    another form with the same button names.
    Otherwise paste the snippet.
    Also you can check what fields are set in the post array by
    adding this to
    the top of (or anywhere on) your page:
    print_r($_POST);
    Cosmo
    "Webethics" <[email protected]> wrote in
    message
    news:[email protected]...
    >
    quote:
    Originally posted by:
    Newsgroup User
    > Off the top of my head this should be no different than
    your radio buttons
    > except that 'productSelection' will always fail the
    !isset check when the
    > form is submitted since the default value is "None", and
    therefore always
    > set. :-)
    >
    > So how about this..?
    > <?php
    > if (isset($_POST['send']) and
    ($_POST['productSelection'] == "None"))
    > {echo "Please select a product.";}
    > ?>
    >
    >
    >
    >
    > "Webethics" <[email protected]> wrote
    in message
    > news:[email protected]...
    > > Another question - how do i applied the code you
    just showed me to
    > > select
    > > menu
    > > or select list?
    > >
    > > This is the list:
    > >
    > > <div class="problemProduct">
    > > <label for="productSelection"><span
    class="product_label">Product
    > > Name.</span></label>
    > > <select name="productSelection" id="products"
    class="selection">
    > > <option value="None">-------------Select a
    product----------</option>
    > > <option value="Everex DVD Burner">Everex DVD
    Burner</option>
    > > <option value="Vidia DVD Burner">Vidia DVD
    Burner</option>
    > > <option value="Excerion Super Drive">Excerion
    Super Drive</option>
    > > <option value="Maxille Optical Multi
    Burner">Maxille Optical Multi
    > > Burner</option>
    > > <option value="Pavilion HD Drives">Pavilion
    HD Drives</option>
    > > </select>
    > > </div>
    > >
    > > I thought I could just change the name is the code
    from operatingSystem
    > > to
    > > productSelection.
    > >
    > > Something like this:
    > >
    > > From this:
    > >
    > > <?php
    > > if (isset($_POST[send]) and
    !isset($_POST['operatingSystem']))
    > > {echo "Please select an operating system.";}
    > > ?>
    > >
    > > To this:
    > >
    > > <?php
    > > if (isset($_POST[send]) and
    !isset($_POST['productSelection']))
    > > {echo "Please select an operating system.";}
    > > ?>
    > >
    > > But this does not work, any ideas?
    > >
    > > Patrick
    > >
    >
    >
    >
    >
    > Hey, I tried this about but as you mentioned, since the
    default product
    > value
    > is "None" an error message appears when the page loads.
    >
    > Is there a way to code this things so that even though
    the default value
    > is
    > "None" there ia no error message untle you hit the
    submit?
    >
    > When I applied the code, it messes up the previous code,
    now the operating
    > system is requiring an entry on page load.
    >
    > When I remove the code from the list menu everything
    goes back to normal.
    >
    > I know this is a little much but I have no other
    alternatives.
    >
    > Patrick
    >

  • Best way to align text with checkboxes/radio buttons?

    Is there a better way to align text and checkboxes/radio
    buttons than using
    tables with vertically-centered cells?
    Reason being, well... you've all tried putting text next to
    those form
    inputs, right? They don't naturally align.

    Thanks, but nothing there really answers my question. :-(
    Anyone know if there's a better way to align text and
    checkboxes/radio
    buttons than using tables with vertically-centered cells?
    Reason being, well... you've all tried putting text next to
    those form
    inputs, right? They don't naturally align. What is the modern
    solution to
    this problem?
    "Nancy O" <[email protected]> wrote in message
    news:gqlm1f$9te$[email protected]..
    >
    http://www.smashingmagazine.com/2006/11/11/css-based-forms-modern-solutions/

  • I have misplaced my iPod Touch 4th Generation. According to Find my iPhone, it should show up in offline mode. I need help on locating it with a software or some other way. Help?

    I have misplaced my iPod Touch 4th Generation. According to Find my iPhone, it should show up in offline mode. I need help on locating it with a software or some other way. Help?

    There is no other way.
    Sorry

  • Need help on struts configuration with ColdFusion 10 using IIS

    We need help on struts configuration with ColdFusion 10 using IIS.
    Earlier we were using ColdFusion 8 with IIS 6 for one of our application.  This application internally calls struts. After upgrading to ColdFusion 10 struts calls are not loading. We get 404 error.
    In ColdFusion 8 struts were configured using  actions extension .do in IIS from this file-
    C:\ColdFusion8\runtime\lib\wsconfig\jrun_iis6.dll.
    But in ColdFusion 10 this file is not present as ColdFusion 10 uses Tomcat in place of Jrun.
    Also there is no information in ColdFusion log file.

    Duane wrote:
    doctormirabilis, Welcome to the discussion area!
    1) how can i configure the time capsule in order to operate as a remote base station synchronizing with the relay using the ethernet port?
    Configure the Time Capsule to act as a bridge (not distributing IP addresses). Also configure the Time Capsule to create an 802.11n wireless network with a unique network name (SSID). That's it.
    2) how can i avoid that my powerbook while accessing my wireless network does connect through the relay station instead of using the time capsule?
    Configure the Time Capsule to use a different network name than the WDS link between the 2 AirPort Express (AX). Configure the PowerBook to use the Time Capsule network.
    There are 2 pieces of information that you should be aware of...
    (1) None of the PowerBooks are capable of 802.11n.
    (2) The WDS link cuts your available bandwidth in half. So the wireless link to your neighbor's has a maximum potential of 27 Mbps.
    Let's for a minute assume that you have a Mac compatible with 802.11n. In your configuration the time you could take advantage of the 802.11n speed is when the Mac is sending/recieving data directly from/to the Time Capsule.
    There would be NO speed increase in Internet access. The speed of Internet access is going to be controlled by the slowest link in the path to the Internet. That is probably the connection to the ISP. The next slowest path is the WDS link to your neighbor's.
    Duane,
    I am in a similar situation, sharing internet with my neighbor. Do you think it would be plausible to hook up a vonage phone adapter to time capsule's ethernet port if time capsule is bridging from my neighbor's router in the configuration you have described? A check of my upload speed shows 1.67Mbps (powerbookG4 w/ airport extreme). Vonage reccommends 90kbps minimum upload speed. Am I going to lose some speed putting the Vonag adapter behind time capsule?
    Thank you

  • Need help re-synching iPods with new computer and getting iTunes to...

    Need help re-synching iPods with new computer and getting iTunes to recognize our iPods (it doesn't even recognize them when they're plugged in).
    Hubby wiped my harddrive for me, so now I need to get everything back in proper places. I'm using windows XP and installed iTunes once again (I believe it's version 8). I also installed all of my iTunes songs. Now I need to know where to go from here. We have 3 iPods and I need to get them all synched once again. I know how to create different libraries for each of us, but I can't figure out how to get our songs back into our iTunes libraries. When I open iTunes and plug in an iPod, iTunes doesn't even show that an iPod is plugged in.
    What do I do now to get each of our iPods synched with our own libraries?
    TIA
    Brandy

    Thanks Zevoneer. The "Restart ipod service" worked and itunes is now recognizing my ipod! Hooray!
    Okay, now how do I synch all of our ipods with our individual libraries (I don't want all of my kids' songs and vice versa)? We each have hundreds of songs on our ipods that we don't want to lose.
    Thanks again!

  • Help with cfinput radio button and text fields

    I have a series of radio buttons that allow a user to select
    monetary values but I also want them to be able to define an amount
    if they choose so. I was planning on doing this by providing a
    radio button with the value of other and then using a text field to
    allow the user to enter the monetary value. The problem with this
    is that they might enter a user defined monetary value but forget
    to set the radio button to "other".
    I was hoping that I could set the "other" text input field to
    read only until the point that the user selects the "other" radio
    button. Is there a way to do this using onSelect or another method.
    Or is there a better way to approach this problem? Thanks for any
    help or advice in advance.

    Hi,
    You could call a js function which will select the radio
    button "other " when the user types something in(there are various
    events on cfinput). This way the user will not have to worry about
    selecting the radio button and your requirement will be satisfied.
    Hope this Helps.
    Thanks,
    Bhakti

  • How to create popup window with radio buttons and a input field

    Hi Guys,
    Can somebody give some directions to create a stand alone program to create a window popup with 2 radio button and an input field for getting text value. I need to update the text value in a custom table.
    I will call this stand alone program from an user exit. 
    Please give me the guidance how go about it or please give any tutorial you have.
    Thanks,
    Mini

    Hi,
    There are multiple aspects of your requirements. So let's take them one at a time.
    You can achieve it in the report program or you can use a combination of the both along.
    You can create a standalone report program using the ABAP Editor (SE38). In the report program you can call the SAP Module pool program by CALL Screen <screen number>. And then in the module pool program you an create a subscreen and can handle the window popup with 2 radio button and an input field for getting the text.
    For help - Module Pool programs you can search in ABAP Editor with DEMODYNPRO* and you will ge the entire demo code for all dialog related code.
    For Report and other Module pool help you can have a look at the following:
    http://help.sap.com/saphelp_nw70/helpdata/en/47/a1ff9b8d0c0986e10000000a42189c/frameset.htm
    Hope this helps. Let me know if you need any more details.
    Thanks,
    Samantak.

  • Yesterday I ran Disk Utility and came up with hundreds of permissions that needed repair.  I hit the "repair permissions" button and waited until it said they were repaired, but just for fun I hit the v

    Yesterday I ran Disk Utility and came up with hundreds of permissions that needed repair.  I hit the "repair permissions" button and waited until it said they were repaired, but just for fun I hit the "verify permissions" button again, and they all came back!  I did this several more times and every time I would hit "verify permissions" I would get the same list.  What's up?  I've always suspected diagnostic programs, but this is Apple's own!

    Ignore them. They aren't errors. You will keep seeing the same ones. As long as you get the message "Permissions repair complete," you're OK.
    http://support.apple.com/kb/TS1448?viewlocale=en_US

  • Is it possible to work with PHP pages in Oracle ERP R12 and how to set up ?

    Hi,
    Is it possible to work with PHP pages in Oracle ERP R12 and how to set up ?
    Regards
    Nandhakumar P

    Hi Nandhakumar,
    To be able to access any Oracle database using PHP you require the following:
    A server with Apache 2+  (Unix, windows etc)
    PHP enabled using OCI8
    tnsnames.ora
    Oracle instant client and associated libraries
    This gives you direct access into oracle database. As for E-Business, you will compromise the security and safty of of R12 by going in through php. Oracle is not likely to support it either.
    I have got a apache/php/Oracle XE working on a test environment and Ithe performance is not a big issue. If you must I would hughly recommend Oracle Linux for quality and security.

  • I need help resetting my security questions, i try to and it says email sent but i never get the email to my main email or alternate email, i never set my questions but somehow there set

    I need help resetting my security questions, i try to and it says email sent but i never get the email to my main email or alternate email, i never set my questions but somehow there set, so i can also not buy apps without entering my question awnsers please help

    Forgotten Security Questions/Answers
    You need to contact Apple by:
    1 - Use the Express lane and start here:
    https://expresslane.apple.com
    then click More Products and Services>Apple ID>Other Apple ID Topics>Forgotten Apple ID security questions.
    or
    Apple - Support -form iTunes Store - Contact Us
    2 - Call Apple in your country by getting the number from here:
    http://support.apple.com/kb/HE57
    or           
    Apple ID: Contacting Apple for help with Apple ID account security
    3 - Use your rescue email address if you set one up
    Rescue email address and how to reset Apple ID security questions
    For general  information see:
    Apple ID: All about Apple ID security questions

  • Hi, I need help!. I will change my iphone and I need to move contacts from one iPhone to the new, what should I do?

    Hi, I need help!. I will change my iphone and I need to move contacts from one iPhone to the new, what should I do?

    You should have been syncing your contact with your computer all along.  Just sync them from the computer to the new iphone.
    iPhone: Transferring information from your current iPhone to a new iPhone

  • Need help to find out link between process order and purchase order.

    Hi All,
    Need help to find out link between process order and purchase order.
    We have purchase order, we can find out associated process order in MD09 (No Purchase Requisition found in Purchase order). When I tired to replicate this scenario with same material in system but not able to do.
    Please suggest me what needs to check to get purchase order link to process order.. (this is not subcontracting )
    Edited by: SAP PQ on Sep 26, 2011 5:24 PM
    Thanks,
    SAP PQ
    Edited by: SAP PQ on Sep 26, 2011 5:24 PM

    MD09 is pegging. In SAP pegging is dynamic, meaning that there's no fixed link between purchase order and process order in your case.
    This is why you did not get the same result when you tried again later.
    Such a link can exist only if you do direct procurement for the order.

  • Radio buttons and Checkboxes to change appearance when selected

    Hi guys!
    Help needed.
    I want my check boxes and radio buttons when selected to change color from black to "0,64,128", size from 12 to 14 and to become bold.
    Also the default appearance for checkboxes is cross, but I need it to be a check mark.
    I would be so much thankful if you could give me some advice.
    THANK YOU!
    Maria

    Hi Bibhu,
    Thanks for quick response!
    For check mark -- thanks! How could I not see that option!
    For radio button -- it's not working.
    I found this helpful tips on changing appearance of the radio buttons and check boxes. http://www.assuredynamics.com/wp-content/uploads/2010/11/Assure-Dynamics-Checkboxes-and-Ra dio-Buttons-Rev-1.pdf
    I used the first script, but I got an error message. I can't understand what I am doing wrong. It says: "Syntax error near token "{" on line 2, column 1.
    I am confused.
    Help appreciated.

  • Multiline checkbox / radio button component

    We're now up to Flash version 8 and we still don't have a
    multiline checkbox / radio button component. Has anyone either:
    a. Figured out how to add a multiline text label to the
    existing Flash components; or
    b. Found a third party component that has multiline labels.
    I'm a developer for an eLearning company, so we use these
    components all the time; so having this would be a huge plus.
    Frankly, it's simply beyond me why Macromedia...er...Adobe hasn't
    upgraded their components to have this feature. It seems like it
    wouldn't be a big thing.
    Anyway, any help you can provide would be most welcome.
    Cheers,
    Adam

    Hopefully this might help.
    http://livedocs.adobe.com/flash/mx2004/main_7_2/00002108.html

Maybe you are looking for