mrcurtains
12-08-2008, 04:32 PM
Hello,
I am new to php and cannot see why this page is not working. I have spent days on trying to find the fault but can't. The problem is that sometimes the form works correctly and sometimes it doesn't. On the receiving page I use _POST to display the contents from the registration form page. Sometimes all of the reults are returned:
array (
'reg1_title' => 'Mr',
'reg1_surname' => 'Bill',
'reg1_forename' => 'Smith',
'reg1_email' => 'Bill@Smith.com',
)
And other times I only get:
array (
)
I have added Javascript to the code (which I have not added to the forum) so the form cannot be submitted without all the fields being completed. I would be very grateful if someone can see what could be wrong. Thank you for your time.
<?php session_start(); ?>
<!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">
<head>
<title>Registration Form</title>
<link rel="STYLESHEET" type="text/css" href="style.css">
</head>
<body>
<?php include_once('include/inc.htmlHeader.php5')?>
<form action="register2.php5" method="POST" name="registrations" onsubmit="return fieldCheck()" style="margin: 0;">
<table cellspacing="0" border="0" id="mainTable">
<tr>
<td class="sectionSingle">
<ul id="info"><li>Fields marked with * must be filled.</li></ul>
<span class="title">Flight Crew - Personal Details</span>
<table cellspacing="0" cellpadding="2">
<tr>
<td width="23"> </td>
<td width="130"><font size="2">Title</font><b class="star"><font size="2">*</font></b></td>
<td colspan="3" width="399"><input maxlength="15" type="text" tabindex="5" name="reg1_title" size="20"></td>
</td>
</tr>
<tr>
<td width="23"> </td>
<td width="130"><font size="2">Surname</font><b class="star"><font size="2">*</font></b></td>
<td colspan="3" width="399"><input maxlength="15" type="text" tabindex="5" name="reg1_surname" size="20"></td>
</tr>
<tr>
<td width="23"> </td>
<td width="130"><font size="2">First Name</font><b class="star"><font size="2">*</font></b></td>
<td colspan="3" width="399"><input maxlength="15" type="text" tabindex="6" name="reg1_forename" size="20"></td>
</tr>
<tr>
<td width="23"> </td>
<td width="130"><font size="2">Email Address</font><b class="star"><font size="2">*</font></b></td>
<td colspan="3" width="399"><input maxlength="35" tabindex="10" type="text" name="reg1_email" size="27"></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<br>
<center><input type="submit" name="btnSubmit" value="Next" tabindex="200"></center>
</form>
</body>
</html>
The following page is the form processing page:
<?php session_start(); ?>
<!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">
<head>
<title>Registration Results</title>
<link rel="STYLESHEET" type="text/css" href="style.css">
<?php
$message = var_export($_POST, true);
$subject = "Registration";
$to = "me@mywebsite.com";
mail($to, $subject, $message);
?>
</head>
<body>
Thank you
</body>
</html>
I am new to php and cannot see why this page is not working. I have spent days on trying to find the fault but can't. The problem is that sometimes the form works correctly and sometimes it doesn't. On the receiving page I use _POST to display the contents from the registration form page. Sometimes all of the reults are returned:
array (
'reg1_title' => 'Mr',
'reg1_surname' => 'Bill',
'reg1_forename' => 'Smith',
'reg1_email' => 'Bill@Smith.com',
)
And other times I only get:
array (
)
I have added Javascript to the code (which I have not added to the forum) so the form cannot be submitted without all the fields being completed. I would be very grateful if someone can see what could be wrong. Thank you for your time.
<?php session_start(); ?>
<!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">
<head>
<title>Registration Form</title>
<link rel="STYLESHEET" type="text/css" href="style.css">
</head>
<body>
<?php include_once('include/inc.htmlHeader.php5')?>
<form action="register2.php5" method="POST" name="registrations" onsubmit="return fieldCheck()" style="margin: 0;">
<table cellspacing="0" border="0" id="mainTable">
<tr>
<td class="sectionSingle">
<ul id="info"><li>Fields marked with * must be filled.</li></ul>
<span class="title">Flight Crew - Personal Details</span>
<table cellspacing="0" cellpadding="2">
<tr>
<td width="23"> </td>
<td width="130"><font size="2">Title</font><b class="star"><font size="2">*</font></b></td>
<td colspan="3" width="399"><input maxlength="15" type="text" tabindex="5" name="reg1_title" size="20"></td>
</td>
</tr>
<tr>
<td width="23"> </td>
<td width="130"><font size="2">Surname</font><b class="star"><font size="2">*</font></b></td>
<td colspan="3" width="399"><input maxlength="15" type="text" tabindex="5" name="reg1_surname" size="20"></td>
</tr>
<tr>
<td width="23"> </td>
<td width="130"><font size="2">First Name</font><b class="star"><font size="2">*</font></b></td>
<td colspan="3" width="399"><input maxlength="15" type="text" tabindex="6" name="reg1_forename" size="20"></td>
</tr>
<tr>
<td width="23"> </td>
<td width="130"><font size="2">Email Address</font><b class="star"><font size="2">*</font></b></td>
<td colspan="3" width="399"><input maxlength="35" tabindex="10" type="text" name="reg1_email" size="27"></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<br>
<center><input type="submit" name="btnSubmit" value="Next" tabindex="200"></center>
</form>
</body>
</html>
The following page is the form processing page:
<?php session_start(); ?>
<!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">
<head>
<title>Registration Results</title>
<link rel="STYLESHEET" type="text/css" href="style.css">
<?php
$message = var_export($_POST, true);
$subject = "Registration";
$to = "me@mywebsite.com";
mail($to, $subject, $message);
?>
</head>
<body>
Thank you
</body>
</html>