dphj737575 2015-09-24 14:01
浏览 13

$ _POST给出未识别的索引错误[重复]

I am making an ajax login script and my html code is as follows :

<form class="form-container" action="login.php" method="POST">
  <div class="form-title"><h2>Sign up</h2></div>
  <div class="form-title">Name</div>
  <input class="form-field" type="text" name="username" /><br />
  <div class="form-title">Password</div>
  <input class="form-field" type="password" name="pass" /><br />
  <div class="submit-container">
    <input class="submit-button" type="submit" value="Submit" />
  </div>
</form>

and my php code is as follows:

$client_username = $_POST["username"];
$client_password = $_POST["pass"]

when i run the code, i get an error in wamp server that says Unidentified Index in my php code. What is wrong and how can i fix it?

EDIT :

I tried this but in vain :

if(isset($_POST["username"]))
{
     $client_username = $_POST["username"];
}

if(isset($_POST["pass"]))
{
  $client_password = $_POST["pass"];
}


echo $client_username;

echo $client_password;
</div>
  • 写回答

1条回答 默认 最新

  • dongshan4878 2015-09-24 14:06
    关注

    Try this, just use isset() to check the POST variables

    $client_username = "";
    $client_password = "";
    
    if(isset($_POST["username"]));
    {
         $client_username = $_POST["username"];
    }
    
    if(isset($_POST["pass"]))
    {
       $client_password = $_POST["pass"];
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析
  • ¥15 生成的QRCode圖片加上下載按鈕
  • ¥15 板材切割优化算法,数学建模,python,lingo