duanke8011 2012-07-07 18:06
浏览 34
已采纳

isset函数与表单在同一页面上不起作用

When I use the isset() function when data is posted from another PHP page it works fine. But when I use the isset() function in the same page to process a form it does not post the data. I see the data in the url but the isset() does not seem to work. The form stays empty and nothing happens.

Here is the form I am currently working on:

<h3>Register</h3>

<?php 
   if(isset($_POST["register_email"],$_POST["register_name"],$_POST["register_password"]))      
   {
       $register_email=$_POST['register_email'];
       $register_name=$_POST['register_name'];
       $register_password=$_POST['register_password'];

       $errors=array();

       if(empty($register_email) || empty($register_name) || empty($register_password))
       {
           $errors[]='All fields required';
       } 

       if(!empty($errors))
       {
           foreach($errors as $error)
           {
               echo $error,'<br />';
           }
       } 
       else {
           echo 'ok';
       }
   }
?>

<form action="" method="">
    <p>Email: <br /><input type="email" name="register_email" size="35" maxlength="255"></p>
    <p>Full name: <br /><input type="text" name="register_name" maxlength="35"></p>
    <p>Password: <br /><input type="password" name="register_password" maxlength="35"></p>
    <p><input type="submit" value="Register"></p>
</form>
  • 写回答

2条回答 默认 最新

  • dongxi5494 2012-07-07 18:33
    关注

    I think you have forgotten to set the form's method to post:

    <form action="" method="post">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)