tags:

views:

59

answers:

1

How to code form element and/or (php) script for this type of form? Thank you everyone.

A: 

You can use hidden text box(or checkbox...) as state holder. When sign-up button clicked this textbox text set to, well, 'signup'(using javascript click handler attached to that sign-up button). Then form submitted. On server-side you can check for this parameter in request. Hope this help.

UPDATE:

<form action="/login.php" method="get">
    <p>
    Login: <input type="text" name="login"><br>
    Password: <INPUT type="text" name="password"><br>
    <input type="submit" name="action" value="Signup"> <input name="action" type="submit" value="Login">
    </p>
 </form>

Is this your form?

Not that when you click Signup action=Signup but when you click Login action=Login

UPDATE 1:


if($_GET('action') == 'Signup'){
   //redirect to full signup form
   header( 'Location: signup.php' ); //note: html tags NOT ALLOWED before this line.
else{
   //process logon (calculate hash and so on)
}

Why do you need separate signup.php? Well, user MUST type his/her password twice. Then you need confirmation e-mail and so on.

You see, this stuff can be implemented in thousand different ways. If you want more useful help you should give me more information. E.g:

1) Do you use MVC? 2) Do you use templates? and so on.

By the way I used GET for clarity(you can see form field values in address bar). In real project you should use POST in form and hence $_POST in login.php

Trickster
on server-side(PHP): if ($_GET['signup'] == 'signup'){}on client-side(jQuery) $('signup_button').click(function(){ $('signup').attr('value','signup');}
Trickster
Do you still have questions?
Trickster
see my updated post
Trickster
You see, Mike. The problem is that you did not told how this form should look. Which fields it contains ? For my form see update.
Trickster
ok it was typo - you should read as "Note that when you click..."
Trickster
Why did you mention "Why do you need separate signup.php?"? Why "user MUST type his/her password twice"?
Mike
ok it can be the same login.php it actually doesn't matter. user must retype his password when he creates new account isn't it?
Trickster
So after all we need both signup.php and login.php?
Mike
Sorry? I think action="/login.php" enables only login but not signup. Otherwise it is somewhat wrong to name the handling php script as "login". In addition the php script (handler?) you gave does not work.
Mike