开发者

Signup and login inputs in a single form

How to code form element and/or (php) script for this type of form? Thank you everyon开发者_StackOverflow社区e.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜