Click to See Complete Forum and Search --> : Submit form error


gavenp
05-31-2007, 04:09 AM
I have a html page that links to a php page and it seems to have a bug in it. IT returns an erroe message when You try to submit the form.

This is what the message is:

Please enter a value for the "regtype" field.

My concern is that I select the type I want but it still does it. Here is the code for the html page:

I am not sure what the problem is.

<HTML>
<HEAD>
<TITLE>Registration</TITLE>

<script Language="JavaScript">
<!--
function Form1_Validator(theForm)
{
if (theForm.regtype.value == "")
{
alert("Please enter a value for the \"regtype\" field.");
theForm.regtype.focus();
return (false);
}
if (theForm.firstname.value == "")
{
alert("Please enter a value for the \"firstname\" field.");
theForm.firstname.focus();
return (false);
}
if (theForm.lastname.value == "")
{
alert("Please enter a value for the \"lastname\" field.");
theForm.firstname.focus();
return (false);
}
if (theForm.username.value == "")
{
alert("Please enter a value for the \"username\" field.");
theForm.firstname.focus();
return (false);
}
if (theForm.email.value == "")
{
alert("Please enter a value for the \"email\" field.");
theForm.email.focus();
return (false);
}
if (theForm.password.value == "")
{
alert("Please enter a value for the \"password\" field.");
theForm.email.focus();
return (false);
}
if (theForm.password.value != theForm.confirm.value)
{
alert("The two passwords are not the same.");
theForm.confirm.focus();
return (false);
}
}

//--></script>
</head>

<BODY>
<p>&nbsp;</p>
<FORM METHOD="POST" ACTION="register.php" onsubmit="return Form1_Validator(this)" language="JavaScript" name="Form1">
<div align="center">
<table width="64%" border="1" cellspacing="0" cellpadding="3" style="border-width: 0px">
<tr valign="middle">
<td style="border-style: none; border-width: medium" colspan="2" bgcolor="#003366">
<b>
<font color="#FFFFFF" face="Verdana" size="2">
Registration Process - Step 1 of 3:
Create your Login </font></b>
</tr>
<tr valign="middle">
<td colspan="2" bgcolor="#FFFFFF" height="44" style="border-style: none; border-width: medium">
<font face="Verdana" style="font-size: 8pt">The following
information allows the system to set up and authenticate you as a
company.&nbsp; No details should be given to anyone not authorised to
act on your companies behalf.&nbsp; All information will be treated in
the strictest confidence as per our <b><font color="#0000FF">Privacy
Policy</font>.</b></font></td>
</tr>
<tr valign="middle">
<td bgcolor="#003366" style="border-style: none; border-width: medium">
<strong><font face="Tahoma" size="2" color="#FFFFFF">Type of
Registration</font></strong></td>
<td style="border-style: none; border-width: medium" bgcolor="#003366">
<b>
<font color="#FFFFFF"><select size="1" name="regtype">
<option selected>Company</option>
<option>Affiliate</option>
<option>Company & Affiliate</option>
<option>Education Facility</option>
<option>Government</option>
<option>Other</option>
</select></font></td>
<tr>
<td colspan="2" bgcolor="#FFFFFF" bordercolor="#FFFFFF" style="border-style: none; border-width: medium"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
* Fields in <b> <font color="#990000">red</font></b> are required</font></td>
</tr>
<tr valign="middle">
<td bgcolor="#CCCCCC" style="border-style: none; border-width: medium">
<font color="#990000" face="Tahoma">
<b>
<strong><font size="2">First Name:</font></strong></font></td>
<td style="border-style: none; border-width: medium">
<b>
<font color="#800000" face="Tahoma" size="1">
<INPUT NAME="firstname" SIZE=25 MAXLENGTH=50 style="font-weight: 700"></font></td>
<tr valign="middle">
<td bgcolor="#CCCCCC" style="border-style: none; border-width: medium">
<font color="#990000" face="Tahoma">
<b>
<strong><font size="2">Last Name:</font></strong></font></td>
<td style="border-style: none; border-width: medium">
<b>
<font color="#800000" face="Tahoma" size="1">
<INPUT NAME="lastname" SIZE=25 MAXLENGTH=50 style="font-weight: 700"></font></td>
<tr valign="middle">
<td bgcolor="#CCCCCC" style="border-style: none; border-width: medium">
<b>
<font face="Tahoma" size="2" color="#990000">
Username:</font></td>
<td style="border-style: none; border-width: medium">
<b>
<font color="#800000" face="Tahoma" size="1">
<INPUT NAME="username" SIZE=15 MAXLENGTH=50 style="font-weight: 700"></font></td>
<tr valign="middle">
<td bgcolor="#CCCCCC" style="border-style: none; border-width: medium">
<b>
<font face="Verdana, Arial, Helvetica, sans-serif" color="#990000" size="2">
Password:</font></td>
<td style="border-style: none; border-width: medium">
<b>
<font color="#800000" face="Tahoma" size="1">
<INPUT TYPE="password" NAME="password" SIZE=15 MAXLENGTH=25 style="font-weight: 700"></font></td>
<tr valign="middle">
<td bgcolor="#CCCCCC" style="border-style: none; border-width: medium">
<b>
<font size="2" color="#990000" face="Tahoma"><strong>Confirm Password:</strong></font></td>
<td style="border-style: none; border-width: medium">
<b>
<font color="#800000" face="Tahoma" size="1">
<INPUT TYPE="password" NAME="confirm" SIZE=15 MAXLENGTH=25 style="font-weight: 700"></font></td>
<tr valign="middle">
<td bgcolor="#CCCCCC" style="border-style: none; border-width: medium">
<b>
<font color="#990000"><strong>
<font face="Tahoma" size="2">E-Mail Address</font></strong></font><font color="#990000" face="Tahoma"><strong><font size="2">:</font></strong></font></td>
<td style="border-style: none; border-width: medium">
<b>
<font color="#800000" face="Tahoma" size="1">
<INPUT NAME="email" SIZE=29 MAXLENGTH=100 style="font-weight: 700"></font></td>
<tr>
<td width="22%" bgcolor="#CCCCCC" bordercolor="#FFFFFF" style="border-style: none; border-width: medium"><b>
<font size="1" color="#990000">&nbsp;</font></b></td>
<td width="77%" bgcolor="#FFFFFF" bordercolor="#FFFFFF" style="border-style: none; border-width: medium"><i><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
&nbsp;A confirmation email will be sent to the email address you specify.</font></i></td>
</tr>
<tr>
<td width="17%" bgcolor="#CCCCCC" bordercolor="#FFFFFF" style="border-style: none; border-width: medium"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
Country</font></b></td>
<td width="68%" bgcolor="#FFFFFF" bordercolor="#FFFFFF" style="border-style: none; border-width: medium">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="country" size="20" maxlength="20">
</font></b></td>
</tr>
<tr>
<td width="17%" bgcolor="#CCCCCC" bordercolor="#FFFFFF" style="border-style: none; border-width: medium"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
Zip Code</font></b></td>
<td width="68%" bgcolor="#FFFFFF" bordercolor="#FFFFFF" style="border-style: none; border-width: medium">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="zipcode" size="20" maxlength="20">
</font></b></td>
</tr>
<tr valign="middle">
<td colspan="2" style="border-style: none; border-width: medium">
<b>
<P style="margin-top: 0; margin-bottom: 0" align="center">
<font color="#800000">
<INPUT TYPE="submit" NAME="submit" VALUE="Submit" style="font-family: Tahoma; font-weight:700"><input type="reset" name="Reset" value="Reset" style="font-weight: 700"></font></p>
</td>
<tr valign="middle">
<td colspan="2" bgcolor="#003366" style="border-style: none; border-width: medium">
<div align="center">&nbsp;</div>
</td>
</BODY>
</HTML>

kiwibrit
05-31-2007, 07:47 AM
I'd remove the javascript alert for regtype. As you are using an option list, one of which will always be selected, I cannot see the point of wanting an alert there. I've not checked the javascript for the rest - javascript is not really my thing. But if you have further troubles, I suggest you post in the javascript section.

gavenp
06-01-2007, 12:52 AM
I did what you said and now it goes to a new page with this message written on it:

Column count doesn't match value count at row 1

kiwibrit
06-01-2007, 01:32 AM
Looks to me that you have a processing problem with your posted information and the script of register.php (is that your new page, btw?) and, perhaps, a database table.