...

View Full Version : displayign message from html form



bluebirdjc
03-26-2007, 08:50 PM
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

_Aerospace_Eng_
03-26-2007, 08:56 PM
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.

Nightfire
03-26-2007, 08:56 PM
You can't have spaces in variable names. Change them to underscores or something

bluebirdjc
03-26-2007, 08:58 PM
thanks guys

bluebirdjc
03-26-2007, 09:26 PM
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

Nightfire
03-26-2007, 09:28 PM
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">

_Aerospace_Eng_
03-26-2007, 10:21 PM
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.

aedrin
03-26-2007, 10:43 PM
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.

_Aerospace_Eng_
03-26-2007, 10:46 PM
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.

Nightfire
03-26-2007, 10:53 PM
plus a closing form tag, when there is no form on the page

aedrin
03-26-2007, 11:15 PM
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".

_Aerospace_Eng_
03-26-2007, 11:19 PM
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.

Fumigator
03-26-2007, 11:29 PM
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 :D

aedrin
03-27-2007, 12:00 AM
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 ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum