drm30963 2015-07-23 11:25
浏览 81

如果声明里面的isset函数不起作用

I am trying to validate my form using php, I am using the isset function to check if the submit button has been clicked. when I click the submit button the code inside the isset function does not execute.

//html


    <div style="width:800px; margin:0px auto 0px auto;">
       <table>
           <tr>
            <td width ="60%" valign="top">
             <h2>join to find friends today</h2>
            </td>

            <td width ="40%" valign="top">
              <h2>Sign up below</h2>

              <form action ="" method"POST">
              <input type="text" name="fname" size ="25"                     placeholder="firstname" /><br/><br/>
              <input type="text" name="lname" size ="25" placeholder="lastname" /><br/><br/>
              <input type="text" name="username" size ="25" placeholder="username"/><br/><br/>
              <input type="text" name="email" size ="25" placeholder="email"/><br/><br/>
              <input type="text" name="email2" size ="25" placeholder="confirm email"/><br/><br/>
              <input type="text" name="password" size ="25" placeholder="password"/><br/><br/>
              <input type="text" name="password2" size ="25" placeholder="confirm password"/><br/><br/>
              <input type="submit" name="reg" value="sign up">

              </form>

            </td>
           </tr>

       </table> 

//php code 

<?php


//declaring variables to prevent errors
$fn = ""; //First Name
$ln = ""; //Last Name
$un = ""; //Username
$em = ""; //Email  
$em2 = ""; //Email 2
$pswd = ""; //Password
$pswd2 = ""; // Password 2
$d = ""; // Sign up Date
$u_check = ""; // Check if username exists
$error ="";

  if (isset($_POST['reg'])) {

//registration form
$fn = strip_tags($_POST['fname']);
$ln = strip_tags($_POST['lname']);
$un = strip_tags($_POST['username']);
$em = strip_tags($_POST['email']);
$em2 = strip_tags($_POST['email2']);
$pswd = strip_tags($_POST['password']);
$pswd2 = strip_tags($_POST['password2']);
$d = date("Y-m-d"); // Year - Month - Day


if(empty($fn)){

 echo 'empty';

 } 
 }
 ?>
  • 写回答

1条回答 默认 最新

  • doujiao6507 2015-07-23 11:31
    关注

    You forgot an = in your <form> tag.

    Replace

    <form action ="" method"POST">
    

    with

    <form action="" method="post">
    

    and it should work.

    评论

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛