duandiaoqian5795 2012-06-05 07:21
浏览 5
已采纳

什么使PHP取消设置形式变量?

My HTML code:

<form class="well" name="login" action="text.php" method="post" >
<input type="text" class="span3" id="username" name"username" placeholder="Enter your valid email">
<input type="text" class="span3" id="password" name"password" placeholder="Enter your password">
<button type="submit" class="btn" >Enzemble </button>
</form>
      <h2>New User? ... Register</h2>
        <form class="well" name="register" action="register.php" method="post" >
            <input type="text" class="span3" id="email" name="email" placeholder="Enter your valid email" onBlur="emailValidation()">
            <button type="submit" class="btn">Enter Enzemble!</button>
        </form> 

The bottom form works fine.

The top code gives "undefined index" notice and does not read values of username and password in text.php The text.php code:

<?php
if (isset($email)) $email=$_POST["username"];
if (isset($password)) $password=$_POST["pasword"];
echo "username " . $email . "password " . $password;
?>

The error: Notice: Undefined index: pasword in /home/nitin/www/enzemble/text.php on line 8 Notice: Undefined variable: email in /home/nitin/www/enzemble/text.php on line 9 username password

I am not getting html form values in php. This is surprising. I am working on it for a long time. Please help.

  • 写回答

6条回答 默认 最新

  • dth981485742 2012-06-05 08:44
    关注

    You have a syntax error in your HTML code. It's missing a = for the name attribute of the input fields:

    <input type="text" class="span3" id="username" name"username" placeholder="Enter your valid email">
    HERE ----------------------------------------------^
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?