click submit twice ... - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-03-2009, 03:56 PM   #1 (permalink)
Regular User
 
Join Date: Nov 2008
Posts: 20
Default click submit twice ...

Hello:

I have this form that checks the validity of data and if everything is correct, clicking the submit button will send them to another filee/form. If things are out of whack, then keep the current page until resolved. This pretty much works other than I have to click the submit button twice which is a royal pain. Is there a way to get by with just 1 click.




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<style>
.errText
{
font-family: Arial;
font-size: 10px;
color: #CC0000;
text-decoration: none;
font-weight: normal;
}
</style>

<title>Verification !!!</title>
</head>
<?php
$errFName = "";
$errMName = "";
$errLName = "";
$frmCounter = 0;

if($_POST["ac"]=="login")
{
// If First Name is NOT letters, dash or spaces then display error message.
if(preg_match("/^[A-Z][a-zA-Z -]+$/", $_POST["fname"]) === 0)
$errFName = '<class="errText">First name must be from letters, dashes, spaces and must not start with dash';
else
$frmCounter = $frmCounter + 1;
// Add validation & Santization here
// If Middle Name is NOT letters, dash and spaces then display error message.
if(preg_match("/^[A-Z][a-zA-Z -]+$/", $_POST["mname"]) === 0)
$errMName = '<class="errText">Middle name must be from letters, dashes, spaces and must not start with dash';
else
$frmCounter = $frmCounter + 1;
// Add validation & Santization here
// If Middle Name is NOT letters, dash and spaces then display error message.
if(preg_match("/^[A-Z][a-zA-Z -]+$/", $_POST["lname"]) === 0)
$errLName = '<class="errText">Last name must be from letters, dashes, spaces and must not start with dash';
else
$frmCounter = $frmCounter + 1;
// Add validation & Santization here
//
if ($frmCounter == 3)
{
$frmSubmit = "connecter.php";
}
else
{
$frmSubmit = $_SERVER['$PHP_SELF'];
}
}
?>

<body>

<form name="main" action="<?php echo $frmSubmit; ?>" method="POST">
<input type="hidden" name="ac" value="login">
<table border="1" width="100%">
<tr>
<td width="124">&nbsp;</td>
<td width="278">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="124" bgcolor="#FFFFFF">
<b><font size="2" face="Arial" color="#3366FF">&nbsp; First Name:</font></b></td>
<td bgcolor="#FFFFFF">
<b><font size="2" face="Arial" color="#FF0000">&nbsp;</font></b>
<input name="fname" style="Width: 262; height:22" maxLength="15" size="2" value="<?php echo $_POST['fname']; ?>" ></td>
<td>&nbsp;<?php if(isset($errFName)) echo $errFName; ?></td>
</tr>
<tr>
<td width="124" bgcolor="#FFFFFF">
<b><font size="2" face="Arial" color="#3366FF">&nbsp; Middle Name:</font></b></td>
<td bgcolor="#FFFFFF">
<b><font size="2" face="Arial" color="#FF0000">&nbsp;</font></b>
<input name="mname" style="Width: 98; height:22" maxLength="15" size="2" value="<?php echo $_POST['mname']; ?>" ></td>
<td>&nbsp;<?php if(isset($errMName)) echo $errMName; ?></td>
</tr>
<tr>
<td width="124" bgcolor="#FFFFFF">
<b><font size="2" face="Arial" color="#3366FF">&nbsp; Last Name:</font></b></td>
<td bgcolor="#FFFFFF">
<b><font size="2" face="Arial" color="#FF0000">&nbsp;</font></b>
<input name="lname" style="Width: 98; height:22" maxLength="25" size="2" value="<?php echo $_POST["lname"]; ?>" ></td>
<td>&nbsp;<?php if(isset($errLName)) echo $errLName; ?></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
pepe_lepew1962 is offline   Reply With Quote
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:37 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting