Results 1 to 3 of 3

Thread: Conditional submit ...

  1. #1
    Join Date
    Nov 2008
    Posts
    52
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Conditional submit ...

    Hello:

    I am trying to change the action portion of my form based on criteria, in this case if the counter is equal to 14 then load thankyou.php, else continue on the PHP Self. What this is is a application form that tests whether all the data is okay. I will work on the santizing later but wanted to get this done as it seems to be the hardest, at least for me.


    <?php
    $frmSubmit = "";
    $errFName = "";

    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
    // more of the above ...
    // more of the above ...
    // more of the above ...
    // more of the above ...

    if $frmCounter = 14
    $frmSubmit = ThankYou.php;
    else
    $frmSubmit = $PHP_SELF;

    }

    ?>

    <body>

    <form name="main" action="<?php $frmSubmit ?>" method="POST"><input type="hidden" name="ac" value="login">

  2. #2
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    So what it looks like is $frmCounter is counting how many areas of the form are successful?

  3. #3
    Join Date
    Nov 2008
    Posts
    52
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Yes Motor that is exactly what I have going. When all the conditions are met then the form has been filled out and I want to then jump to the thankyou.php page ( file ). If something is missing or incorrect, then stay on they PHP_SELF page until the problem is fixed.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •