ThemeForest

Two forms on one page?

962 posts
  • Has been a member for 2-3 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Grew a moustache for the Envato Movember competition
  • Beta Tester
  • Exclusive Author
  • Sold between 1 000 and 5 000 dollars
  • Bought between 10 and 49 items
  • United States
webdesigndeluxe says

Hey everyone, I’m kind of having some troubles. I have built a login form with the register page built into the same login page. There is a jquery slider, so if they click “login” it will slide to the login form. If they click the “register” link , it will slide to the register form.

The problem I am having is submitting the forms. I am validating both forms, but say I fill out the register form, it will slide back to the login form and ask to type in an email and password.

So I’m wondering if there is a type of code that does this:

If the register submit button is clicked it will only verify the register form. And if the login submit button is clicked it will only validate the login form.

I really like the effect with the two forms on the same page, but I really want to get them both working properly.

Thanks for any help you can provide me with!

2 years ago
73 posts
  • Has been a member for 1-2 years
  • Beta Tester
  • Exclusive Author
  • Sold between 1 and 100 dollars
  • Bought between 50 and 99 items
  • United States
jalexsmith says

I’m doing something very similar, actually. It’s a problem with the IDs and the Names of the fields…...you’ll have to differentiate them somehow….. I haven’t finished the project yet, but I should start working on that part tomorrow.

I’ll be interested in this thread for sure.

2 years ago
94 posts
  • Has been a member for 2-3 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Bought between 50 and 99 items
  • Netherlands
  • Referred between 10 and 49 users
ceasar says

Does the jquery make the slide back or the backend code ? Like @jalessmith writes it’s the id’s and the name of the filelds. Sent me you html code (or post all the code here) and I will have a look and advice what to change.

2 years ago
101 posts
  • Has been a member for 2-3 years
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 100 and 499 items
  • United Kingdom
  • Referred between 1 and 9 users
RyanDavies says

Hi

Without seeing the page code, I can only offer a broad answer / advice.

as mentioned, it is all in the ids of your page elements. HTML id’s are there specifically for this reason, so that you additional code / scripts can look for / target values in specific elements of the page.

I am not sure whether you are doing this all via JS + Ajax for the validation, if that is the case that my example will get very generalised.

For php validation, you should simply need to look for a specific submit variable id, so for example, if you had 2 submit buttons, one with an id of “login” and another with an id of “register”, you would need to add some code like this to your php header :

if(isset($_POST['register'])) {
     // register user
} elseif(isset($_POST['login'])) {
     // log user in
}

Javascript / ajax would use similar logic, just slightly different implementation.

$('#login').click(function() {
    // login stuff
});
$('#register').click(function() {
    // register stuff
});

Thats just a brief how to off the top of my head, if I have gone down the wrong road, then I apologize :) although some sample code / example page would help people give you a nailed down answer :)

Ryan

2 years ago
by
by
by
by
by