Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    displayign message from html form

    im having trouble dispalying a message using php after pressing a submit button i have created for a form in html

    Here is my hmtl code

    <html>
    <head>
    <title>contactform</title>
    </head>

    <form method="POST" action="proccessform2.php">
    <body>
    <br>
    This is a contact form for making comments on his website or you are intrested in a house advertised on our website then please fill out this form and send to us and our help team will contact you back as soon as possible.
    <br><br>
    First Name: <input type="text" name="first">
    <br><br>
    Second Name: <input type="text" name="last">
    <br><br>
    Telephone: <input type="text" name="telephone">
    <br><br>
    Email Address: <input type="text" name="email">
    <br><br>
    Mobile: <input type="text" name="mobile">
    <br><br>
    Address line 1 please enter house number: <input name="addressline1">
    <br><br>
    Address line 2 please enter street name: <input name="addressline2">
    <br><br>
    Address line 3 please enter area located: <input name="addressline3">
    <br><br>
    Please give the city or town you live in: <input name="city">
    <br><br>
    Are you intrested in a house: <input type="checkbox" name="are you intrested in a house" VALUE="are you intrested in a house">
    <br><br>

    Area located:
    <select name="area located">
    <option selected>No house selected
    <option>Roath
    <option>Splott
    <option>Whitchurch
    <option>Ely
    <option>Grangetown
    <option>Llanrummney
    <option>Rummney
    <option>Tremorfa
    <option>Canton
    <option>Bluetown
    <option>Llandaff
    </select>
    <br><br>
    Please give house name: <input type="text" name="hname">
    <br><br>

    <p>
    Comments: <textarea name="Comments" rows="5" cols="45">Comments are...</textarea>
    <br><BR>
    <input type="submit" name="submit" value="submit form">
    <br>
    <br>
    <A HREF="Homepage.html">home</A>
    </form>
    </body>

    <html>

    and this is my php code

    <html>
    <head>
    <title>Results of contact form</title>
    </head>

    <body>
    <?php
    $firstname = $_REQUEST["first"];
    $secondname = $_REQUEST["last"];

    $telephone = $_REQUEST["telephone"];
    $email = $_REQUEST["email"];
    $mobile = $_REQUEST["mobile"];
    $address line 1 = $_REQUEST["addressline1"];
    $address line 2 = $_REQUEST["addressline2"];
    $address line 3 = $_REQUEST["adressline3"];
    $city or town = $_REQUEST["city"];
    $are you interested in a house= $_REQUEST["areyouintrestedinahouse"];
    $area = $_REQUEST["arealocated"];
    $house name = $_REQUEST["hname"];
    $comments = $_REQUEST["comments"];

    echo "Thank you for completing this form we will get back top you as soon as possible"
    ?>
    </form>
    </body>

    </html>

    anyone know what i have done wrong

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You should be getting some errors. Variables can't have spaces in them. In your area located section you put no values in the options so that will never get sent to the script. Also your HTML is quite bad. I recommend that you actually learn html well before you try doing more php. It seems like you might be trying to walk before you can crawl. Also don't use $_REQUEST, instead use $_POST.
    Last edited by _Aerospace_Eng_; 03-26-2007 at 08:59 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    You can't have spaces in variable names. Change them to underscores or something

  • #4
    New Coder
    Join Date
    Mar 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks guys

  • #5
    New Coder
    Join Date
    Mar 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    damm still not working ive changed the php code to this

    <html>
    <head>
    <title>Results of contact form</title>
    </head>

    <body>
    <?php
    $firstname = $_POST["first"];
    $secondname = $_POST["last"];

    $telephone = $_POST["telephone"];
    $email = $_POST["email"];
    $mobile = $_POST["mobile"];
    $address_line_1 = $_POST["addressline1"];
    $address_line_2 = $_POST["addressline2"];
    $address_line_3 = $_POST["adressline3"];
    $city_ or_town = $_POST["city"];
    $are_you_interested_in_a_house= $_POST["areyouintrestedinahouse"];
    $area = $_POST["arealocated"];
    $house_name = $_POST["hname"];
    $comments = $_POST["comments"];

    echo "Thank you for completing this form we will get back top you as soon as possible"
    ?>
    </form>
    </body>

    </html>

    can anyone spot anything wrogn with this and html. sorry im just a poor student with little knowledge on php

  • #6
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Looks fine to me. What error are you getting? Have you changed the names in the html form to reflect on what you're calling the variables?

    <input type="checkbox" name="are you intrested in a house"> to
    <input type="checkbox" name="areyouintrestedinahouse">

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Move your form tag into the body and not out of it. Also check the spelling on your filename that processes the script. In the form you have
    action="proccessform2.php"

    Note process is spelt with 1 c and not two so I think your form processing page only has 1 c.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #8
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Also your HTML is quite bad
    Actually, to me it appears to be proper HTML 4.01.

    The only "issue" is this:

    <form method="POST" action="proccessform2.php">
    <body>
    Those 2 lines should be switched.

  • #9
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by aedrin View Post
    Actually, to me it appears to be proper HTML 4.01.

    The only "issue" is this:



    Those 2 lines should be switched.
    Umm no. That is one of the issues yes but it has no doctype, it has no content-type meta tag and it has no closing option tags though I do believe those are optional.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #10
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    plus a closing form tag, when there is no form on the page

  • #11
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    That is one of the issues yes but it has no doctype, it has no content-type meta tag and it has no closing option tags though I do believe those are optional.
    Closing option tag is indeed optional.

    I didn't know DOCTYPE was required, but apparently it is (although it still seems strange).

    I see no requirement for the content-type.

    plus a closing form tag, when there is no form on the page
    I only checked the first page, as the second was just HTML. So I suppose you are correct about that. Nothing a decent IDE wouldn't have caught.

    So 1 thing that isn't really required (Doctype) and 1 thing that was most likely a copy & paste messup (who doesn't do that?), and you think it is "quite bad".

    I just wanted to point out that I see a lot worse HTML than this, and that it doesn't warrant a "quite bad".

  • #12
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Okay now we are getting a bit off topic but just to point out the doctype is required. If you don't have one you will find yourself spending countless hours trying to hack up IE just to get it to look right. Step back and go learn HTML properly.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #13
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    One thing we know about aedrin, he doesn't like to back down once he's taken a position, no matter how wrong that position is

  • #14
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Hey, try administrating a game with several young people who won't back down either. You tend to build up a shield to protect yourself from getting caught off guard.

    That, and I like discussing things


  •  

    Posting Permissions

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