Dynamic php form -


i'm trying login form change based on if user 'new' or 'existing'. example if 'existing user' selected display 'username', , 'password' input fields. while choosing 'new user' 'username','email','password', , 'passwordconfirm'.

<select id="login_type" name="logintype">  <option value="register">a new user</option>   <option value="login">an existing user</option> </select>  

tried code below got stuck when read html form inside if else. can to?

<?php if (isset($_post['login_type']) && $_post['login_type'] == 'an existing user')  {  <div>     <label for="uname_input">username:</label>     <input id="uname_input" name="uname" type="text" required="required" placeholder="enter username"/>     <br />     <label for="pass_input">password:</label>     <input id="pass_input" name="passwd" type="password" required="required" placeholder="enter password"/> </div>   <input id="submit_login" type="submit" value="submit" />   }  else  {      <div class="shownew">         <label for="em_input">email:</label>         <input id="em_input" name="email" type="text"  placeholder="enter valid email address"/>     </div>     <div>         <label for="uname_input">username:</label>         <input id="uname_input" name="uname" type="text" required="required" placeholder="enter username"/>         <br />         <label for="pass_input">password:</label>         <input id="pass_input" name="passwd" type="password" required="required" placeholder="enter password"/>     </div>     <div class="shownew">         <label for="pass2_input">confirm:</label>         <input id="pass2_input" name="passwd2" type="password" placeholder="repeat password"/>     </div>      <input id="submit_login" type="submit" value="submit" />  }  if (isset($_get['error'])) {   $errmsg = '';   switch ($_get['error'])   {   case 1: $errmsg = 'passwords entered not match 1 another.'; break;   case 2: $errmsg = 'username exists in database. please choose             different username.'; break;   case 3: $errmsg = 'the username or password entered incorrect. please try again.'; break;   case 4: $errmsg = 'invalid login mode. please reload page , try again.'; break;   case 5: $errmsg = 'unexpected error processing login. please try again'; break;   default: $errmsg = 'an unknown error occurred. please try again in few minutes.'; break;   }   print '<p class="errmsg">' . $errmsg . '</p>'; } ?> 

looks have missing php opening / closing tags :

if (isset($_post['login_type']) && $_post['login_type'] == 'an existing user')  {  <div> 

should

if (isset($_post['login_type']) && $_post['login_type'] == 'an existing user')  { ?>  <div> 

etc...


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -