Q:

2 forms in a single page: One for desktop and the other for a mobile screen in PHP

I have 2 forms in a page, but basically the form action, method and fields name are the same. I have made these two forms because one form is for desktop and the other is for a mobile screen. I am just hiding one form when it is a desktop screen and not a mobile screen. When I am using post, in the next page it is showing me a null value. I am not getting any post value.  Can anyone suggest why this is happening?
/* for dekstop*/
<div class="LregisterI"><br><div class="close"><img src="<?=$img_loc?>close.png" id="btnClose"/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
      <div class="Lregister">
    <form action="line_check.php" class="form" name="reg" method="POST" >
        <table border="0" align="center" width="" style="">
            <tr>
                <td colspan="4">
                    <img src="<?=$img_loc?>regi.png" />
                </td>
            </tr>
            <tr>
                <td align="" width="78">Name</td>
                <td>
                    <input type="text" id="name" name="name" value=""  onfocus="document.getElementsByClassName('err1')[0].innerHTML=''" class="inputstyle h" />
                </td>
                <td align="center">Gender</td>
                <td>
                    <div class="gender">
                        <div class="umale">
                            <input type="radio" name="gender" checked value="Male">
                            <label>Male</label>
                        </div>
                        <div class="ufemale">
                            <input type="radio" name="gender" value="Female">
                            <label>Female</label>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td align="" width="78"></td>
                <td height="10">
                    <div class="err err1" id="err1"></div>
                </td>
                <td align="center"></td>
                <td>
                    <div></div>
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <div class="hline"></div>
                </td>
            </tr>
            <tr>
                <td height="10" colspan="4"></td>
            </tr>
            <tr>
                <td align="">Password</td>
                <td>
                    <input type="password" id="pword"  name="pword" value="" onfocus="document.getElementsByClassName('err2')[0].innerHTML=''" class="inputstyle" />
                </td>
                <td align="center">Confirm Password</td>
                <td>
                   <input type="password" id="spword"  name="spword" value="" onfocus="document.getElementsByClassName('err3')[0].innerHTML=''" value="" class="inputstyle" />
                </td>
            </tr>
            <tr>
                <td align="" width="78"></td>
                <td height="20">
                    <div class="err err2" id=""></div>
                </td>
                <td align="center"></td>
                <td>
                    <div class="err err3" id=""></div>
                </td>
            </tr>
            <tr>
                <td align="">Email</td>
                <td>
                    <input type="text" id="email" name="email" onfocus="document.getElementsByClassName('err4')[0].innerHTML=''" class="inputstyle" />
                </td>
                <td align="center">Collage</td>
                <td>
                    <input type="text" id="college" name="college" onfocus="document.getElementsByClassName('err5')[0].innerHTML=''" value="" class="inputstyle" />
                </td>
            </tr>
            <tr>
                <td align="" width="78"></td>
                <td height="20">
                    <div class="err err4" id=""></div>
                </td>
                <td align="center"></td>
                <td>
                    <div class="err err5" id=""></div>
                </td>
            </tr>
            <tr>
                <td align="">Mobile</td>
                <td>
                    <input type="hidden" name="reg" value="register">
                    <input type="text" id="no" name="number" value="" onfocus="document.getElementsByClassName('err6')[0].innerHTML=''" class="inputstyle" />
                </td>
                <td align="center">City</td>
                <td>
                    <input type="text" id="city" name="city" value="" onfocus="document.getElementsByClassName('err7')[0].innerHTML=''" class="inputstyle" />
                </td>
            </tr>
            <tr>
                <td align="" width="78"></td>
                <td height="10">
                    <div class="err err6" id=""></div>
                </td>
                <td align="center"></td>
                <td>
                    <div class="err err7"  id=""></div>
                </td>
            </tr>
            <tr>
                <td align="" width="78"></td>
                <td colspan="3">
                    <input type="button" name="sub1" class="submit" value="" onclick="chk();"  />
                </td>
            </tr>
        </table>
    </form>
</div>

/* for Mobile*/     
<div class="LregisterS">
          <form action="line_check.php" class="form" name="reg" method="POST" >
            <img src="./static/img/regi.png" height="43">

              <div class="name">
              <div class="fl">Name</div>
             <input type="text" id="name" name="name"  onfocus="document.getElementsByClassName('err1')[1].innerHTML=''" class="inputstyle h fr"  />
              </div>
              <div class="err1 mT er " id=""></div>
              <div class="name" >
              <div class="fl" style="width:186px;">Gender</div>
              <div class="umale fr"><input type="radio" name="gender" checked value="Male" class="umaleI" /><label>Male</label></div>
              <div class="ufemale fr" ><input type="radio" name="gender" value="Female" class="ufemaleI" /> <label>Female</label></div>
              </div>
              <div class="email">
              <div class="fl">Password</div>
              <input type="password" id="pword"  name="pword" value=""  onfocus="document.getElementsByClassName('err2')[1].innerHTML=''" class="inputstyle h fr"  />
              </div>
              <div class="err2 mT er " id=""></div>
              <div class="mobile">
              <div class="fl">Confirm Password</div>
             <input type="password" id="spword"  name="spword" value=""  onfocus="document.getElementsByClassName('err3')[1].innerHTML=''" class="inputstyle h fr"  />
              </div>
              <div class="err3 mT er " id=""></div>
              <div class="email">
              <div class="fl">Email</div>
              <input type="hidden" name="reg" value="register">
               <input type="text" id="email" name="email" onfocus="document.getElementsByClassName('err4')[1].innerHTML=''" class="inputstyle h fr"  />
              </div>
              <div class="err4 mT er" id=""></div>
              <div class="mobile">
               <div class="fl">Collage</div>
                <input type="text" id="college" name="college" onfocus="document.getElementsByClassName('err5')[1].innerHTML=''" class="inputstyle h fr"  />
              </div>
              <div class="err5 mT er" id=""></div>
              <div class="mobile">
               <div class="fl">Mobile</div>
             <input type="text" id="no" name="number" value="" onfocus="document.getElementsByClassName('err6')[1].innerHTML=''" value="" class="inputstyle h fr"  />
              </div>
              <div class="err6 mT er " id=""></div>
              <div class="mobile">
               <div class="fl">City</div>
             <input type="text" id="city" name="city" value="" onfocus="document.getElementsByClassName('err7')[1].innerHTML=''" value="" class="inputstyle h fr"  />
              </div>
              <div class="err7 mT er " id=""></div>

              <div class="sub"><input type="button" name="sub" class="submit" value="" onclick="chk();" /></div>
             </form> 
           </div>

      </div>

A:

I think for this purpose you need to use $_SERVER['HTTP_USER_AGENT'] function in php. Use it and check if it is from pc or from the mobiel

