2014-01-16 22 views
-1

這是我第一次創建一個網站,我想在一個頁面上註冊和登錄表單。每次我嘗試註冊時,都會迴應登錄的數據,基本上這個過程會停止。如果我獨立使用寄存器,它工作得很好。由於我使用引導,我的整個代碼都在一個大的(但註冊/登錄清楚地分開)。有沒有什麼方法可以指導PHP只回應我工作的細分市場?兩個PHP回聲在一個.php文件中。我可以將它們隔離嗎?

<!-- Form Code Start --> 
<div id='fg_membersite' class="container"> 
    <div class="row"> 
     <div class="col-md-3"> 
      <form id='register' class="form-horizontal" action='<?php echo $fgmembersite->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'> 
       <fieldset > 
        <legend>Register</legend> 

        <input type='hidden' name='submitted' id='submitted' value='1'/> 

        <div class='short_explanation'>* required fields</div> 
        <input type='text' class='spmhidip' name='<?php echo $fgmembersite->GetSpamTrapInputName(); ?>' /> 

        <div><span class='error'><?php echo $fgmembersite->GetErrorMessage(); ?></span></div> 
        <div class='container'> 
         <label for='name' >Your Full Name*: </label><br/> 
         <input type='text' name='name' id='name' value='<?php echo $fgmembersite->SafeDisplay('name') ?>' maxlength="50" /><br/> 
         <span id='register_name_errorloc' class='error'></span> 
        </div> 
        <div class='container'> 
         <label for='email' >Email Address*:</label><br/> 
         <input type='text' name='email' id='email' value='<?php echo $fgmembersite->SafeDisplay('email') ?>' maxlength="50" /><br/> 
         <span id='register_email_errorloc' class='error'></span> 
        </div> 
        <div class='container'> 
         <label for='username' >UserName*:</label><br/> 
         <input type='text' name='username' id='username' value='<?php echo $fgmembersite->SafeDisplay('username') ?>' maxlength="50" /><br/> 
         <span id='register_username_errorloc' class='error'></span> 
        </div> 
        <div class='container' style='height:80px;'> 
         <label for='password' >Password*:</label><br/> 
         <div class='pwdwidgetdiv' id='thepwddiv' ></div> 
         <noscript> 
          <input type='password' name='password' id='password' maxlength="50" /> 
         </noscript> 
         <div id='register_password_errorloc' class='error' style='clear:both'></div> 
        </div> 

        <div class='container'> 
         <input type='submit' name='Submit' value='Submit' /> 
        </div> 

       </fieldset> 
      </form> 
     </div> 

     <div class="col-md-3"> 
      <form id='login' class="form-horizontal" action='<?php echo $fgmembersite->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'> 
       <fieldset > 
        <legend>Login</legend> 

        <input type='hidden' name='submitted' id='submitted' value='1'/> 

        <div class='short_explanation'>* required fields</div> 

        <div><span class='error'><?php echo $fgmembersite->GetErrorMessage(); ?></span></div> 
        <div class='container'> 
         <label for='username' >UserName*:</label><br/> 
         <input type='text' name='username' id='username' value='<?php echo $fgmembersite->SafeDisplay('username') ?>' maxlength="50" /><br/> 
         <span id='login_username_errorloc' class='error'></span> 
        </div> 
        <div class='container'> 
         <label for='password' >Password*:</label><br/> 
         <input type='password' name='password' id='password' maxlength="50" /><br/> 
         <span id='login_password_errorloc' class='error'></span> 
        </div> 

        <div class='container'> 
         <input type='submit' name='Submit' value='Submit' /> 
        </div> 
        <div class='short_explanation'><a href='reset-pwd-req.php'>Forgot Password?</a></div> 
       </fieldset> 
      </form> 
     </div> 
    </div> 
+2

如何在沒有提供相關代碼的情況下解決您的問題? –

+0

是可能的,到目前爲止你有什麼? – Steve

+0

hellooo代碼....代碼.....你在哪裏? –

回答

1

你可以這樣建立它:

<?php if ($someBool): ?> 
    <form id="register"> 
     <!-- more html here --> 
    </form> 
<? else: ?> 
    <form id="login"> 
     <!-- yet more html here --> 
    </form> 
<?php endif ?> 

它的替代語法if。請參閱http://pl1.php.net/alternative_syntax

相關問題