dangillow
11-11-2006, 04:18 AM
Hi There,
I seem to be having issues with my form and inserting those values into my database. I have my form in one file and PHP form processing in another file.
When the user clicks submit, my PHP form processing file is called and it process's the form. After all fields have been validated. When user clicks the submit button its greyed out to prevent multiple clicks and entrys my PHP form processing file is called but nothing happens, just a blank screen. I know the form is working fine as it was before I added the javascript validation.
I have recently added some javascript validation to check my form and grey out the submit button once clicked.
http://www.webdeveloper.com/forum/showthread.php?p=665859#post665859
I posted on this site yesterday for some help on my javascript validation. That all seems to be fine now. Is there something wrong with my my form or my PHP processing script?
I have posted both bits of code below. Thank you for reading. This is driving me nuts right now :confused:
FORM CODE
<script language="JavaScript" type="text/javascript">
<!--
function checkform ( form )
{
if (document.getElementById("forename").value.length <2) {
alert( "Please Enter Your Forename" );
document.getElementById("forename").focus();
return false ;
}
if (document.getElementById("surname").value.length <2) {
alert( "Please Enter Your Surname" );
document.getElementById("surname").focus();
return false ;
}
if (document.getElementById("telephone_extension").value.length <3) {
alert( "Please Enter Your Telephone Extension" );
document.getElementById("telephone_extension").focus();
return false ;
}
if (document.getElementById("email").value.length <5) {
alert( "Please Enter Your E-Mail" );
document.getElementById("email").focus();
return false ;
}
if (document.getElementById("location").value.length <2) {
alert( "Please Provide Your Room Location" );
document.getElementById("location").focus();
return false ;
}
document.getElementById("submitButton").disabled = true;
form.submit();
return true ;
}
//-->
</script>
</head>
<body>
<div align="center"><h2>Create User</h2></div>
<form action="create_user_processing.php" method="post">
<fieldset>
<legend>Contact Details</legend>
<p>
<label for="forename">Forename:<em class="required"> (Required)</em></label>
<input style="background-color:#ffc;" name="forename" id=forename" type="text" maxlength="30"/>
</p>
<p>
<label for="surname">Surname:<em class="required"> (Required)</em></label>
<input style="background-color:#ffc;" name="surname" id=surname" type="text" maxlength="30"/>
</p>
<p>
<label for="telephone_extension">Telephone Extension:</label>
<input style="background-color:#ffc;" name="telephone_extension" id=telephone_extension" type="text" maxlength="15"/>
</p>
<p>
<label for="email">E-Mail:<em class="required"> (Required)</em></label>
<input style="background-color:#ffc;" name="email" id=email" type="text" maxlength="30"/>
</p>
<p>
<label for="location">Location:<em class="required"> (Required)</em></label>
<input style="background-color:#ffc;" name="location" id=location" type="text" maxlength="20"/>
</p>
<input type="reset" name="reset" value="Reset" />
<input type="button" name="submitButton" id="submitButton" onclick="checkform(this.form)" value="Submit"/>
</fieldset>
</form>
PHP FORM PROCESSING
// Assign the query
$query = "INSERT INTO user (id, user_id, forename, surname, telephone_extension, email, location)
VALUES ('{$_POST['id']}', '{$_POST['user_id']}', '{$_POST['forename']}', '{$_POST['surname']}', '{$_POST['telephone_extension']}' , '{$_POST['email']}', '{$_POST['location']}')";
// Execute the query
if (@mysql_query ($query))
{
print '<h3>User Successfully Created</h3>';
}
else
{
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}
Thank you
Danny
I seem to be having issues with my form and inserting those values into my database. I have my form in one file and PHP form processing in another file.
When the user clicks submit, my PHP form processing file is called and it process's the form. After all fields have been validated. When user clicks the submit button its greyed out to prevent multiple clicks and entrys my PHP form processing file is called but nothing happens, just a blank screen. I know the form is working fine as it was before I added the javascript validation.
I have recently added some javascript validation to check my form and grey out the submit button once clicked.
http://www.webdeveloper.com/forum/showthread.php?p=665859#post665859
I posted on this site yesterday for some help on my javascript validation. That all seems to be fine now. Is there something wrong with my my form or my PHP processing script?
I have posted both bits of code below. Thank you for reading. This is driving me nuts right now :confused:
FORM CODE
<script language="JavaScript" type="text/javascript">
<!--
function checkform ( form )
{
if (document.getElementById("forename").value.length <2) {
alert( "Please Enter Your Forename" );
document.getElementById("forename").focus();
return false ;
}
if (document.getElementById("surname").value.length <2) {
alert( "Please Enter Your Surname" );
document.getElementById("surname").focus();
return false ;
}
if (document.getElementById("telephone_extension").value.length <3) {
alert( "Please Enter Your Telephone Extension" );
document.getElementById("telephone_extension").focus();
return false ;
}
if (document.getElementById("email").value.length <5) {
alert( "Please Enter Your E-Mail" );
document.getElementById("email").focus();
return false ;
}
if (document.getElementById("location").value.length <2) {
alert( "Please Provide Your Room Location" );
document.getElementById("location").focus();
return false ;
}
document.getElementById("submitButton").disabled = true;
form.submit();
return true ;
}
//-->
</script>
</head>
<body>
<div align="center"><h2>Create User</h2></div>
<form action="create_user_processing.php" method="post">
<fieldset>
<legend>Contact Details</legend>
<p>
<label for="forename">Forename:<em class="required"> (Required)</em></label>
<input style="background-color:#ffc;" name="forename" id=forename" type="text" maxlength="30"/>
</p>
<p>
<label for="surname">Surname:<em class="required"> (Required)</em></label>
<input style="background-color:#ffc;" name="surname" id=surname" type="text" maxlength="30"/>
</p>
<p>
<label for="telephone_extension">Telephone Extension:</label>
<input style="background-color:#ffc;" name="telephone_extension" id=telephone_extension" type="text" maxlength="15"/>
</p>
<p>
<label for="email">E-Mail:<em class="required"> (Required)</em></label>
<input style="background-color:#ffc;" name="email" id=email" type="text" maxlength="30"/>
</p>
<p>
<label for="location">Location:<em class="required"> (Required)</em></label>
<input style="background-color:#ffc;" name="location" id=location" type="text" maxlength="20"/>
</p>
<input type="reset" name="reset" value="Reset" />
<input type="button" name="submitButton" id="submitButton" onclick="checkform(this.form)" value="Submit"/>
</fieldset>
</form>
PHP FORM PROCESSING
// Assign the query
$query = "INSERT INTO user (id, user_id, forename, surname, telephone_extension, email, location)
VALUES ('{$_POST['id']}', '{$_POST['user_id']}', '{$_POST['forename']}', '{$_POST['surname']}', '{$_POST['telephone_extension']}' , '{$_POST['email']}', '{$_POST['location']}')";
// Execute the query
if (@mysql_query ($query))
{
print '<h3>User Successfully Created</h3>';
}
else
{
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}
Thank you
Danny