How to submit the data although it return false?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smartic
    New Member
    • May 2007
    • 150

    How to submit the data although it return false?

    im having two problems with my site, i wrote Javascript code into my page to return true if the data that was entered was correct else return false and im having two buttons to submit the data
    EX:

    this button to check for availability and the other to check that all data are correct to insert into it database in the same form.
    EX:

    The other problem, i want to login in the same page im already on and make the form disappear when i enter the correct data how to do that
    EX:
  • nathj
    Recognized Expert Contributor
    • May 2007
    • 937

    #2
    Originally posted by smartic
    im having two problems with my site, i wrote Javascript code into my page to return true if the data that was entered was correct else return false and im having two buttons to submit the data
    EX:

    this button to check for availability and the other to check that all data are correct to insert into it database in the same form.
    EX:

    The other problem, i want to login in the same page im already on and make the form disappear when i enter the correct data how to do that
    EX:
    If I understand, and forgive me if I don't, you want the login page to POST the form data back to itself and then display something different if the login was sucessful?

    If this is the case I would have the login page first check $_POST data to see if the items have been set. If they have then check if they are correct. If they have not then display the form.

    If the items are correct display what you want to display to users logged in otherwise show the form with some text explaining the error and offering help such as reminders.

    Here's some psuedo code.
    [CODE=php]
    if (isset($_POST['user']) && isset($_POST['password']))
    {
    if(username=val id && password=valid) //psuedocode
    {
    $lnIsValid 0;
    }
    else
    {
    $lnIsValid = 2;
    }
    }
    else // not set
    {
    $lnIsValid = 1;
    }

    switch($lnIsVal id)
    {
    case 0:
    echo "Welcome";
    break;
    case 1: // display form for the first time
    include("form.p hp") ; // we can then use this later
    break;
    case 2:
    include("form.p hp");
    echo "the data entered did not match do you need assistance"; //offer password reminder etc
    break;
    }
    [/CODE]

    This is just a quick peice of psuedo code, but hopefully it will point you in the right direction.

    Don't forget, you can always post back if you need more help
    Cheers
    nathj

    Comment

    • smartic
      New Member
      • May 2007
      • 150

      #3
      Thank you for replay but my real problem is i;m having javascript into the form [HTML]onsubmit="retur n validation()"[/HTML] when i click the availability button it check if all the data are correct and don't return thing thank you.

      Comment

      Working...