click submit twice ...

Discussion in 'PHP' started by pepe_lepew1962, Feb 3, 2009.

  1. #1
    Hi:

    I have this script running pretty well accept for the fact that I need to click submit TWICE for it to continue. Can someone help me so that I only have to click it once to continue.

    Thanks



    <!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, Feb 3, 2009 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
  3. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #3
    What do u mean by that? I think your form should submit once clicked ( 1 time )
     
    ads2help, Feb 4, 2009 IP
  4. vic_msn

    vic_msn Well-Known Member

    Messages:
    2,233
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    155
    #4
    may be you can use javascript confirm box to proceed with the request or not
    fyi the confirm box returns true or false.
     
    vic_msn, Feb 4, 2009 IP
  5. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #5
    oh sorry.. i thought you are talking about the possible spams.
    yep.. why not use confirm box. or instead of type="submit" replace it with onDoubleClick="submit the form function"
     
    bartolay13, Feb 4, 2009 IP