By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,940 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,940 IT Pros & Developers. It's quick & easy.

How to submit the data although it return false?

100+
P: 150
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:

Jul 23 '07 #1
Share this Question
Share on Google+
2 Replies


nathj
Expert 100+
P: 938
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.
Expand|Select|Wrap|Line Numbers
  1. if (isset($_POST['user']) && isset($_POST['password']))
  2. {
  3.   if(username=valid && password=valid) //psuedocode
  4.   {
  5.   $lnIsValid  0;
  6.   }
  7.   else
  8.   {
  9.   $lnIsValid = 2;
  10.   }
  11. }
  12. else // not set
  13. {
  14.   $lnIsValid = 1;
  15. }
  16.  
  17. switch($lnIsValid)
  18. {
  19.   case 0:
  20.    echo "Welcome";
  21.    break;
  22.   case 1: // display form for the first time
  23.    include("form.php") ; // we can then use this later
  24.    break;
  25.   case 2:
  26.    include("form.php");
  27.    echo "the data entered did not match do you need assistance"; //offer password reminder etc
  28.   break;
  29. }
  30.  
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
Jul 23 '07 #2

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

Post your reply

Sign in to post your reply or Sign up for a free account.