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条)

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 深度学习残差模块模型
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)