PDA

View Full Version : Help with form


JBD
02-22-2009, 12:45 AM
Can anyone see why this form isn't working correctly?

Any help would be much appreciated :)

JBD

http://www.firstaccommodation.co.uk/tenants.html

the php:

<?php

$Surname = $_POST['Surname'];
$First_Name = $_POST['First_Name'];
$Address = $_POST['Address'];
$Email = $_POST['Email'];
$Work_Phone = $_POST['Work_Phone'];
$Home_Phone = $_POST['Home_Phone'];
$DOB = $_POST['DOB'];
$Occupation = $_POST['Occupation'];
$Employer_Name_Address= $_POST['Employer_Name_Address'];
$Housing_Benefit = $_POST['Housing_Benefit'];
$Number_People_Living_At_Property = $_POST['Number_People_Living_At_Property'];
$Move_In_Date = $_POST['Move_In_Date'];
$Children = $_POST['Children'];
$Children_Ages = $_POST['Children_Ages'];
$Pets = $_POST['Pets'];
$Area_Accommodation_Required = $_POST['Area_Accommodation_Required'];

$url = "http://www.firstaccommodation.co.uk.html";

$recipient = "mail@jonballdesign.co.uk";
$subject = 'First Accommodation Application';

$message = "Surname: $Surname \n";
$message .= "First_Name: $First Name \n";
$message .= "Address: $Address \n";
$message .= "Email: $Email \n";
$message .= "Work_Phone: $Work Number \n";
$message .= "Home_Phone: $Home Number\n";
$message .= "DOB: $DOB \n";
$message .= "Occupation: $Occupation \n";
$message .= "Employer_Name_Address: $Employer Details \n";
$message .= "Housing_Benefit: $Housing Benefits \n";
$message .= "Number_People_Living_At_Property: $Number_People_Living_At_Property \n";
$message .= "Comments on office staff telephone response: $officeresponse \n";
$message .= "Move_In_Date: $Move in date \n";
$message .= "Children: $Children \n";
$message .= "Children_Ages: $Children Ages \n";
$message .= "Pets: $Pets \n";
$message .= "Area_Accommodation_Required: $Area \n";


$headers = "From: $name";

mail($recipient,$subject,$message,$headers);
header ("Location: $url");

?> //

davidj
02-22-2009, 01:48 AM
where you running it from

your local machine or a host?

JBD
02-22-2009, 08:51 AM
a host (www.1and1.co.uk)

davidj
02-22-2009, 08:58 AM
ok

how is it not working correctly

JBD
02-22-2009, 03:03 PM
well I don't receive an email with the results and when you hit submit it links to a forbidden page. For now the idea is to return to the index page, once that works I'll add some kind of 'thanks for submitting your application' page...

davidj
02-22-2009, 05:25 PM
check your $url value

is it correct?

it has a domain and an html defined

JBD
02-22-2009, 08:17 PM
sorry I've looked over and over and I still can't see what I've done wrong

davidj
02-22-2009, 10:08 PM
is this correct


$url = "http://www.firstaccommodation.co.uk.html";

JBD
02-23-2009, 07:02 PM
Obviously you are trying to point something out to me but I have no idea. This is only the second time I've used php and as much as I've looked into this online I still don't know what I'm doing wrong. Perhaps it's glaringly obvious to you but I don't see how when I press submit it tries to access this link:

http://www.firstaccommodation.co.uk/applicationform.php

This is my php form which shows how I've changed the url you are highlighting to one that will display a 'thank you' page:

<?php

$Surname = $_POST['Surname'];
$First_Name = $_POST['First_Name'];
$Address = $_POST['Address'];
$Email = $_POST['Email'];
$Work_Phone = $_POST['Work_Phone'];
$Home_Phone = $_POST['Home_Phone'];
$DOB = $_POST['DOB'];
$Occupation = $_POST['Occupation'];
$Employer_Name_Address= $_POST['Employer_Name_Address'];
$Housing_Benefit = $_POST['Housing_Benefit'];
$Number_People_Living_At_Property = $_POST['Number_People_Living_At_Property'];
$Move_In_Date = $_POST['Move_In_Date'];
$Children = $_POST['Children'];
$Children_Ages = $_POST['Children_Ages'];
$Pets = $_POST['Pets'];
$Area_Accommodation_Required = $_POST['Area_Accommodation_Required'];

$url = "http://www.firstaccommodation.co.uk/sent.html";

$recipient = "mail@jonballdesign.co.uk";
$subject = 'First Accommodation Application';

$message = "Surname: $Surname \n";
$message .= "First_Name: $First Name \n";
$message .= "Address: $Address \n";
$message .= "Email: $Email \n";
$message .= "Work_Phone: $Work Number \n";
$message .= "Home_Phone: $Home Number\n";
$message .= "DOB: $DOB \n";
$message .= "Occupation: $Occupation \n";
$message .= "Employer_Name_Address: $Employer Details \n";
$message .= "Housing_Benefit: $Housing Benefits \n";
$message .= "Number_People_Living_At_Property: $Number_People_Living_At_Property \n";
$message .= "Comments on office staff telephone response: $officeresponse \n";
$message .= "Move_In_Date: $Move in date \n";
$message .= "Children: $Children \n";
$message .= "Children_Ages: $Children Ages \n";
$message .= "Pets: $Pets \n";
$message .= "Area_Accommodation_Required: $Area \n";


$headers = "From: $name";

mail($recipient,$subject,$message,$headers);
header ("Location: $url");

?> //

If you know the solution I'd really appreciate a simple answer.

Thanks

davidj
02-23-2009, 08:32 PM
set the $url variable to index.htm

this will redirect to the index page

why its not mailing you i have no idea

it looks ok to me

davidj
02-23-2009, 08:44 PM
If you know the solution I'd really appreciate a simple answer.


I enjoy teaching and i do this for free. During my time on this forum i have helped a handfull of individuals achieve a level of programming knowledge which they have built on. This is through teaching those who want to learn. Ive no interest in those who dont.

Rob_Che
02-23-2009, 10:04 PM
Obviously you are trying to point something out to me but I have no idea.

DJ isn't that subtle :wink:

JBD
02-23-2009, 10:17 PM
just tried that but it still replies with the same error msg. Surely php would work fine with the 1and1 servers... if you have no idea then I'm kinda stuffed unless anyone else does????

davidj
02-23-2009, 10:24 PM
i think everyone should have a basic understanding of the languages they want to work with. If they dont they should do a basic primer

if i write some code and the user see's this ....

$%$^^%%$$$%^^&&**

The only way to help is to write the solution then i dont think this is very helpfull at all.

I prefer to teach a skill.

davidj
02-23-2009, 10:25 PM
repost your code as it is now

JBD
02-23-2009, 10:32 PM
... and I am trying to learn, I've spent hours looking into this problem now going over and over the code whilst referring to numerous other sites explaining php. I know you were saying to change the $url but I also know I used 'http://www..................co.uk.html' within the last form I did and that worked fine so I couldn't understand why you were suggesting that was the problem. I appreciate very much the experience and knowledge of people on this forum and I'm very happy to be able to learn through their free advice.

JBD
02-23-2009, 10:33 PM
<?php

$Surname = $_POST['Surname'];
$First_Name = $_POST['First_Name'];
$Address = $_POST['Address'];
$Email = $_POST['Email'];
$Work_Phone = $_POST['Work_Phone'];
$Home_Phone = $_POST['Home_Phone'];
$DOB = $_POST['DOB'];
$Occupation = $_POST['Occupation'];
$Employer_Name_Address= $_POST['Employer_Name_Address'];
$Housing_Benefit = $_POST['Housing_Benefit'];
$Number_People_Living_At_Property = $_POST['Number_People_Living_At_Property'];
$Move_In_Date = $_POST['Move_In_Date'];
$Children = $_POST['Children'];
$Children_Ages = $_POST['Children_Ages'];
$Pets = $_POST['Pets'];
$Area_Accommodation_Required = $_POST['Area_Accommodation_Required'];

$url = "index.htm";

$recipient = "mail@jonballdesign.co.uk";
$subject = 'First Accommodation Application';

$message = "Surname: $Surname \n";
$message .= "First_Name: $First Name \n";
$message .= "Address: $Address \n";
$message .= "Email: $Email \n";
$message .= "Work_Phone: $Work Number \n";
$message .= "Home_Phone: $Home Number\n";
$message .= "DOB: $DOB \n";
$message .= "Occupation: $Occupation \n";
$message .= "Employer_Name_Address: $Employer Details \n";
$message .= "Housing_Benefit: $Housing Benefits \n";
$message .= "Number_People_Living_At_Property: $Number_People_Living_At_Property \n";
$message .= "Comments on office staff telephone response: $officeresponse \n";
$message .= "Move_In_Date: $Move in date \n";
$message .= "Children: $Children \n";
$message .= "Children_Ages: $Children Ages \n";
$message .= "Pets: $Pets \n";
$message .= "Area_Accommodation_Required: $Area \n";


$headers = "From: $name";

mail($recipient,$subject,$message,$headers);
header ("Location: $url");

?> //

davidj
02-23-2009, 10:50 PM
first where you have


header ("Location: $url");

add an


exit;

just a precaution i use

example...



header ("Location: $url");

exit;



another thing

lets debug this

first strip it back so you have nothing on the page

add the mail function on its own upload it and then browse it in order to run it and see if you get a mail


$recipient = "your-address-here";
$subject = "test";
$message = "test";
$headers = "test";
mail($recipient,$subject,$message,$headers);

JBD
02-23-2009, 11:14 PM
php simplified to:

<?php

$recipient = "mail@jonballdesign.co.uk";
$subject = "test";
$message = "test";
$headers = "test";
mail($recipient,$subject,$message,$headers);

?> //

html simplified to:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Bristol Accomodation, English Course, Come to Bristol, Go to Bristol, Share House, Au Pair, Study English, English School, Come to England" />
<title>First Accommodation l Tenants</title>
<link rel="stylesheet" href="stylesheets/master.css" type="text/css" media="screen" title="master" charset="utf-8" />
<!--[if IE 6]>
<link rel="stylesheet" href="stylesheets/ie6.css" type="text/css" media="screen" title="ie6 fixes" charset="utf-8" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" href="stylesheets/ie7.css" type="text/css" media="screen" title="ie6 fixes" charset="utf-8" />
<![endif]-->
</head>

<body>
<div id="container">
<div id="header">
<h1>FirstAccommodation.co.uk</h1>
</div>
<div id="nav">
<ul id="menu">
<li><a href="index.htm">Home</a></li>
<li><a href="properties.htm">Properties to let</a></li>
<li><a href="landlords.htm">Landlords</a></li>
<li><strong>Application Form</strong></li>
<li><a href="about-bristol.htm">About Bristol</a></li>
<li><a href="contact-us.htm">Contact us</a></li>
</ul>
</div>
<div id="content">
<div id="mainContent" class="services accommodation">

</div>

<div id="middleContent2">
<div id="middleContentInnertenants" class="mainhome">
<div id="middleContentText">
<h2>Application Form</h2>


</head>

<body bgcolor="#FFFFFF" background="images/back.gif" bgproperties="fixed" vlink="#3333FF" onLoad="goforit()">

<table width="590" border="0" cellspacing="0" cellpadding="0" height="1112">
<tr>
<td height="1112" valign="top">
<p>&nbsp;</p>

<p>&nbsp;</p>
<p><font face="Arial, Helvetica, sans-serif" size="2">When registering with
First Accommodation, please make sure </font><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><font color="#FF0000">(Required)</font></font>
<font size="2" face="Arial, Helvetica, sans-serif">fields are filled in,
otherwise the form will be rejected.</font></p>
<p>&nbsp;</p>

<form
action="http://www.firstaccommodation.co.uk/applicationform.php"
method="POST" name="Application Form" id="Application Form">


<table width="559" border="0" cellspacing="0" cellpadding="5">
<tr bgcolor="#F3F3F3" valign="top">
<td width="86"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Surname<br>
<font color="#FF0000">(Required) </font></font></td>
<td> <font size="1" face="Verdana, Arial, Helvetica, sans-serif">

<td>
<input type="reset" name="Reset" value="Reset"> </td>

<td>
<input type="Submit" value="Submit!"> </td>
</tr>
</table>
</form>

<p><em>If you find accommodation through First Accommodation our fees are as follows:</em><br />
<em><br />
85 (per tenant) for 1 bedroom property or one room let in a share house.</em></p>
<em>&nbsp;<br />
158 for 2 or more bedrooms property, based on a maximum of three people sharing, any additional tenants will be charged at 50.</em> </td>
</tr>
</table>
</div>
</div>
</div>

<div id="servicesContent" class="clearfix">
<ul id="homeServices">
<li id="accom">
<h3>Ask for our properties list</h3>
<p><a href="contact-us.htm">Click here</a></p>
</li>
<li id="bristolabout">
<h3>Bristol, a city</h3>
<h3>full of life</h3>
<p><a href="about-bristol.htm">Click here</a></p></li>
<li id="english">
<h3>A professional and</h3>
<h3>friendly service</h3></li>
</ul>
</div>

</div>
<div id="footer">
<p>&nbsp;</p>
<p>
<a href="http://www.firstaccommodation.co.uk/properties.html">Properties</a> l
<a href="http://www.firstaccommodation.co.uk/landlords.html">Landlords</a> l
<a href="http://www.firstaccommodation.co.uk/tenants.html">Application Form</a> l
<a href="http://www.firstaccommodation.co.uk/about-bristol.html">About Bristol</a> l
<a href="http://www.firstaccommodation.co.uk/links.html">Links</a> l
<a href="http://www.firstaccommodation.co.uk/legal.html">Legal</a> l
<a href="http://www.firstaccommodation.co.uk/contact-us.html">Contact us</a>
</p>
<p>&nbsp;</p>
<p>Copyright 2009 First Accommodation. All rights reserved. Website by <a href="http://jonballdesign.co.uk/" target="_blank">jonballdesign.co.uk</a></p>
</div>
</div>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-1194216-1";
urchinTracker();
</script>
</body>
</html>

JBD
02-23-2009, 11:20 PM
if that's what you meant it still gives the same error and no email

davidj
02-24-2009, 05:33 AM
your form action is pointing to

http://www.firstaccommodation.co.uk/applicationform.php


could this be the problem of the forbidden page? and the reason your php is not processing?

davidj
02-24-2009, 08:15 AM
is the mail function in your applicationform.php

JBD
02-24-2009, 12:49 PM
I've changed the form action to just 'applicationform.php' and this is the exact code in the php file

<?php

$recipient = "mail@jonballdesign.co.uk";
$subject = "test";
$message = "test";
$headers = "test";
mail($recipient,$subject,$message,$headers);

?>

have i missed anything out?

davidj
02-24-2009, 01:16 PM
so in the 'applicationform.php' you have the mail function php?

JBD
02-24-2009, 01:33 PM
in the php file I have put exactly what you said to put unless I have misunderstood you?

davidj
02-24-2009, 01:35 PM
yes but

your form is submitting to a page called 'applicationform.php'

unless you have the PHP in a page called 'applicationform.php' then the php wont run

do you know how forms work?

JBD
02-24-2009, 01:51 PM
I've only ever used a form once in which I got help from people on this forum. This is the form:

http://www.cannonsecurity.co.uk/CannonsecurityCustomerserviceform.html

and this is the php:

<?php

$name = $_POST['Name'];
$ref = $_POST['RefNumber'];
$question1 = $_POST['_questone'];
$punctuality = $_POST['punctuality'];
$question2 = $_POST['_questtwo'];
$attitude = $_POST['attitude'];
$question3 = $_POST['_questthree'];
$engineersresponse = $_POST['engineersresponse'];
$question4 = $_POST['_questfour'];
$cleanliness = $_POST['cleanliness'];
$question5 = $_POST['_questfive'];
$officeresponse = $_POST['officeresponse'];
$question6 = $_POST['_questsix'];
$officemanner = $_POST['officemanner'];
$question7 = $_POST['_questseven'];
$officequeries = $_POST['officequeries'];
$question8 = $_POST['_questeight'];
$officecomplaints = $_POST['officecomplaints'];
$othercomments = $_POST['othercomments'];

$url = "http://www.cannonsecurity.co.uk/Cannonsecuritysurveycomplete.htm#http://www.cannonsecurity.co.uk/Cannonsecurityhome.htm";

$recipient = "dominic@cannonsecurity.co.uk";
$subject = 'Website Customer Survey Form';

$message = "Name: $name \n";
$message .= "Reference Number: $ref \n";
$message .= "Engineers Punctuality: $question1 \n";
$message .= "Comments on engineers punctuality: $punctuality \n";
$message .= "Engineers attitude: $question2 \n";
$message .= "Comments of engineers attitude: $attitude \n";
$message .= "Engineers response: $question3 \n";
$message .= "Comments on engineers response: $engineersresponse \n";
$message .= "Cleanliness: $question4 \n";
$message .= "Comments on engineers cleanliness: $cleanliness \n";
$message .= "Office Response: $question5 \n";
$message .= "Comments on office staff telephone response: $officeresponse \n";
$message .= "Office Manner: $question6 \n";
$message .= "Comments on office staff telephone manner: $officemanner \n";
$message .= "Office Queries: $question7 \n";
$message .= "Comments on office staff's respone to queries: $officequeries \n";
$message .= "Office Complaints: $question8 \n";
$message .= "Comments on office staff response to complaints: $officecomplaints \n";
$message .= "Other Comments: $othercomments \n";

$headers = "From: $name";

mail($recipient,$subject,$message,$headers);
header ("Location: $url");

?>

I know this form works and so I thought by using it as a starting point I could apply it to the website I'm working on now.

I simply cannot see what I have done differently to make this new form not work?

I thought I had a basic idea of how they work but it seems not.

davidj
02-24-2009, 01:53 PM
if the form is on that page then the action of the form needs to point to the same page in order for the form to submit to the php

JBD
02-24-2009, 02:21 PM
I've read that sentence over and over and I so want to understand what you're getting at but I'm still confused...

the form is on this page:

http://www.firstaccommodation.co.uk/tenants.html

the php file is called 'applicationform.php' and only contains the code you said to use.

the ACTION within the html on the form page points to the 'applicationform.php' file

I've used exactly the same html/php code as the first form I mentioned and so I can't see why I'm getting an error this time.

davidj
02-24-2009, 04:31 PM
when you upload the 'applicationform.php' page make sure you have the correct rights set

set it to 777 via your FTP client once its uploaded

JBD
02-24-2009, 09:11 PM
Ok I've tried that and this appears to do nothing, are you sure 777 is necessary as the other form I used worked fine on 644. Do I need to give full read/write/execute access?

davidj
02-24-2009, 09:23 PM
then i dont know what it is

ask your host if there is anything they know

JBD
02-24-2009, 09:27 PM
ok I'll try emailing them

JBD
03-04-2009, 08:51 PM
After all that it turned out my client only had a basic package with their host which doesn't support php... now waiting for them to upgrade.

davidj
03-05-2009, 05:35 AM
OMG :shock:

{BANGS HEAD OFF TABLE}