Page 1 of 1

PHP FORMS

Posted: Thu Mar 31, 2011 10:28 am
by hayward
Hey Iv just written a form on a website for a client, my client needs this form to capture the customers details and then pre-populate those onto a separate document so the customer is able to print it sign and return as its a declaration, Iv written the form in html as that's what I read to do, the document that will capture the details Iv written in PHP, Iv connected the form to the PHP document which I have uploaded to the same host as the website only when I click submit on the form its taking me to an empty page on the website and saying "Page not found" has anyone els occurred this problem? if so what can I do to prevent it?

Cheers

Re: PHP FORMS

Posted: Thu Mar 31, 2011 11:11 am
by litebearer
Show us both you form page AND your php page. Also are both files in the same folder?

Re: PHP FORMS

Posted: Fri Apr 01, 2011 5:38 am
by hayward
hey Iv managed to get them connected only the php form is not picking up the input information now ?
HERES THE FORM CODE -
<html>
<body>
<form action="http://www.freepensionreview.com/feed_back.php" method="post">
<fieldset>
<ol>
<li><label for="form-name">Name:</label> </br><input type="text" name="name" id="form-name" /></li>
<li><label for="form-address">Address:</label> </br><textarea name="story" rows "5" cols="22"></textarea></li>
<li><label for="form-date of birth">Date of Birth:</label> </br><input type="text" Date of Birth="Date of Birth" /></li>
<li><label for="form-national insurance no">National Insurance No:</label> </br><input type="text" National Insurance No="National Insurance No" /></li>
<li><label for="form-policy number">Policy Number:</label> </br><input type="text" Policy Number="Policy Number" /></li>
<li><label for="insurance company">Insurance Company:</label> </br><input type="text" Insurance Company="Insurance Company" /></li>
<li><label for="form-Add More Policy numbers and they're company names">Add More Policy numbers and they're company names:</label> </br><textarea name="story" rows="5" cols="22"></textarea></li>
</ol>
</fieldset>
<p><input type="submit" value="Submit" /></p>
</form>
</body>
</html>

AND HERES THE PHP CODE -
<!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" lang="en" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Thank you for entering</title>
<style type="text/css">
body {margin: 20px;
font-family: Verdana, Helvetica, sans-serif;
font-size: 90%;}
h1 {border-bottom: 1px solid;}
h2 {font-size: 1.2em;}
</style>
</head>
<body>
<h1>THANK YOU</h1>


<h1><img src="final-logo.jpg" alt="final logo"/></h1>


<p>Thank you for completing our Free Review Form. We would be grateful if you could print & sign this declaration and return it to our Free Post address:</p>


<p>I hereby confirm that I have appointed Bartholomew Hawkins Ltd of One Waterton Park, Bridgend, CF313PH as my financial advisors and they are to be the serving agents for the future in respect of my policies. Please confirm in writing that records have been amended to this effect and that all information associated agreements are transferred to them, if applicable.</p>


<h2>Your Details:</h2>
<ul>
<li><strong>Name:</strong> <em>empty</em></li>
<li><strong>Address:</strong> <em>empty</em></li>
<li><strong>Date of Birth:</strong> <em>empty</em></li>
<li><strong>National Insurance No:</strong> <em>empty</em></li>
<li><strong>Policy Number:</strong> <em>empty</em></li>
<li><strong>Insurance Company:</strong> <em>empty</em></li>
<li><strong>Add more policy numbers and their company names:</strong> <em>empty</em></li>
</ul>

</body>
</html>

Re: PHP FORMS

Posted: Fri Apr 01, 2011 7:49 am
by litebearer
you have NO php coding in either page, take a look at this tutorial http://www.tizag.com/phpT/forms.php

Re: PHP FORMS

Posted: Mon Apr 04, 2011 10:59 am
by hayward
Cheers this was a great help as php is all new to me i think iv almost cracked this form issue only im having this message when i click the submit button
- Parse error: syntax error, unexpected T_STRING in /home/content/07/7417407/html/your_information.php on line 4-
Iv checked out line 4 an I dont c any problems with it, any ideas?
form 1
<html>
<head>
<title>Your Details</title>
</head>
<body>
<form action="http://www.freepensionreview.com/your_information.php" method="post">
Name:</br><input type="text" size="12" maxlength="12" name="name"><br />
Address:</br><textarea rows="4" cols="20" name="quote" wrap="physical"></textarea><br />
Date of Birth:</br><input type="text" size="12" maxlength="12" name="Date of Birth"><br />
National Insurance Number:</br><input type="text" size="12" maxlength="12" name="National Insurance Number"><br />
Policy Number:</br><input type="text" size="12" maxlength="12" name="Policy Number"><br />
Insurance Company:</br><input type="text" size="12" maxlength="12" name="Insurance Company"><br />
Add More Policy numbers and their company names:</br><textarea rows="5" cols="20" name="quote" wrap="physical"></textarea><br />
<input type="submit" value="submit" name="submit"><br />
</form><br />
form 2
<?php
$Name = $_POST["name"];
$Address = $_POST["address"];
$Date of birth = $_POST["date of birth"];
$National insurance number = $_POST["national insurance number"];
$Policy number = $_POST["policy number"];
$Insurance number = $_POST["insurance number"];
$Add more policy numbers and their company names = $_POST["add more policy numbers and their company names"];
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<html>
<head>
<title>Your Details</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Name:</br><input type="text" size="12" maxlength="12" name="name"><br />
Address:</br><textarea rows="4" cols="20" name="quote" wrap="physical"></textarea><br />
Date of Birth:</br><input type="text" size="12" maxlength="12" name="Date of Birth"><br />
National Insurance Number:</br><input type="text" size="12" maxlength="12" name="National Insurance Number"><br />
Policy Number:</br><input type="text" size="12" maxlength="12" name="Policy Number"><br />
Insurance Company:</br><input type="text" size="12" maxlength="12" name="Insurance Company"><br />
Add More Policy numbers and their company names:</br><textarea rows="5" cols="20" name="quote" wrap="physical"></textarea><br />
<input type="submit" value="submit" name="submit">
</form>
<?
} else {
echo "Name, ".$name.".<br />";
echo "Address, ".$address.".<br />";
echo "Date of Birth, ".$date of Birth.".<br />";
echo "National Insurance Number, ".$national insurance number.".<br />";
echo "Policy Number, ".$policy number.".<br />";
echo "Insurance Company, ".$insurance company.".<br />";
echo "Add more policy numbers and their company names, ".Add more policy numbers and their company names.".<br />";
}
?>

cheers

Re: PHP FORMS

Posted: Mon Apr 04, 2011 12:19 pm
by social_experiment
hayward wrote:- Parse error: syntax error, unexpected T_STRING in /home/content/07/7417407/html/your_information.php on line 4-
The error is on the page called your_information.php. From your previous posts, im guessing that the code you pasted, is not that page. You have to paste the code for your_information.php

Code: Select all

$Date of birth = $_POST["date of birth"];
$National insurance number = $_POST["national insurance number"];
$Policy number = $_POST["policy number"];
$Insurance number = $_POST["insurance number"];
$Add more policy numbers and their company names = $_POST["add more policy numbers and their company names"];
These variables are also going to give you trouble. Variable names cannot contains spaces. Try camel casing or use an underscore where you need a space.

Code: Select all

$Date_of_birth = $_POST['date of birth'];

Re: PHP FORMS

Posted: Tue Apr 05, 2011 10:37 am
by hayward
The forms I posted previously have now changed I created new forms under the names form 1 = input_form.php and form 2 = your_information.php this was a great help cheers think iv almost completed my first php form I have managed to capture the first question on the form "Name" only the rest don't seem to be capturing can anyone see the problem?

Form 1
<html>
<head>
<title>Your Details</title>
</head>
<body>
<form action="http://www.freepensionreview.com/your_information.php" method="post">
Name:</br><input type="text" size="12" maxlength="12" name="name"><br />
Address:</br><textarea rows="4" cols="20" name="quote" wrap="physical"></textarea><br />
Date of Birth:</br><input type="text" size="12" maxlength="12" name="Date of Birth"><br />
National Insurance Number:</br><input type="text" size="12" maxlength="12" name="National Insurance Number"><br />
Policy Number:</br><input type="text" size="12" maxlength="12" name="Policy Number"><br />
Insurance Company:</br><input type="text" size="12" maxlength="12" name="Insurance Company"><br />
Add More Policy numbers and their company names:</br><textarea rows="5" cols="20" name="quote" wrap="physical"></textarea><br />
<input type="submit" value="submit" name="submit"><br />
</form><br />
Form 2
<?php
$Name = $_POST["name"];
$Address = $_POST["Address"];
$Date_of_Birth = $_POST[ "Date of Birth" ] ;
$National_Insurance_Number = $_POST["National Insurance Number"];
$Policy_Number = $_POST["Policy Number"];
$Insurance_Number = $_POST["Insurance Number"];
$Add_more_policy_numbers_and_their_company_names = $_POST["Add more policy numbers and their company names"];
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<html>
<head>
<title>Your Details</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Name:</br><input type="text" size="12" maxlength="12" name="name"><br />
Address:</br><textarea rows="4" cols="20" name="quote" wrap="physical"></textarea><br />
Date of Birth:</br><input type="text" size="12" maxlength="12" name="Date of Birth"><br />
National Insurance Number:</br><input type="text" size="12" maxlength="12" name="National Insurance Number"><br />
Policy Number:</br><input type="text" size="12" maxlength="12" name="Policy Number"><br />
Insurance Company:</br><input type="text" size="12" maxlength="12" name="Insurance Company"><br />
Add More Policy numbers and their company names:</br><textarea rows="5" cols="20" name="quote" wrap="physical"></textarea><br />
<input type="submit" value="submit" name="submit">
</form>
<?
} else {
echo "Name, ".$Name. " .<br />";
echo "Address, ".$Address.".<br />";
echo "Date_of_Birth, ".$Date_of_Birth.".<br />";
echo "National_Insurance_Number, ".$National_Insurance_Number.".<br />";
echo "Policy_Number, ".$Policy_Number.".<br />";
echo "Insurance_Number, ".$Insurance_Number.".<br />";
echo "Add_more_policy_numbers_and_their_company_names, ".$Add_more_policy_numbers_and_their_company_names.".<br />";
}
?>





<h1><img src="final-logo.jpg" alt="final logo"/></h1>

<p>Thank you for completing our Free Review Form. We would be grateful if you could print & sign this declaration and return it to our Free Post address:</p>


<p>
I hereby confirm that I have appointed Bartholomew Hawkins Ltd of One Waterton Park, Bridgend, CF313PH as my financial advisors and they are to be the serving agents for the future in respect of my policies. Please confirm in writing that records have been amended to this effect and that all information associated agreements are transferred to them, if applicable.</p>

<p>Please sign...................................................................</p>

Re: PHP FORMS

Posted: Tue Apr 05, 2011 11:36 am
by social_experiment

Code: Select all

Date of Birth:</br><input type="text" size="12" maxlength="12" name="Date of Birth">
<!-- change to -->
Date of Birth:</br><input type="text" size="12" maxlength="12" name="Date_of_Birth">
<!-- $_POST['Date_of_Birth'] will contain the date of birth data. -->
It could be that you are having the same problem here as i pointed out earlier. In the address field, you give the textarea the name attribute of 'quote' but in your php code, you try to access this $Address = $_POST["Address"];. It should be $_POST['quote']

Re: PHP FORMS

Posted: Wed Apr 06, 2011 4:24 am
by hayward
Ah I c apologies its all new to me, cheers that was a great help!