首页 > 解决方案 > 用php制作的登录表单中的索引错误

问题描述

我正在尝试使用 php 制作登录表单,但出现此错误。“注意:未定义的索引:第 218 行 C:\xampp\htdocs\practica\login.php 中的actiune”

我以前使用的代码在较旧的 xampp 版本上工作,但现在我遇到了这个问题。

<form method="post" action="/login.php?actiune=conectare">
  <div class="imgcontainer">
    <img src="/practica/poza/log_in.png" alt="Avatar" class="avatar">
  </div>

  <div class="container">
    <label for="uname"><b>Username</b></label>
    <input type="text" placeholder="Enter Username" name="uname" required>

    <label for="psw"><b>Password</b></label>
    <input type="password" placeholder="Enter Password" name="psw" required>
        
    <button type="submit">Login</button>
    <label>
      <input type="checkbox" checked="checked" name="remember"> Remember me
    </label>
  </div>

  <div class="container" style="background-color:#f1f1f1">
    <button type="button" class="cancelbtn">Cancel</button>
    <span class="psw">Forgot <a href="#">password?</a></span>
  </div>
</form>
</div>



</body>
</html>
<?php
require_once('config.php');
if($_GET['actiune']=="conectare")
{$sql="SELECT * FROM utilizatori WHERE email='".$_POST['email']."' AND parola='".$_POST['psw']."'";
$rez=mysql_query($sql);
if(mysql_num_rows($rez)==0)
echo 'Ati gresit parola sau nu sunteti inregistrat';
else
{$_SESION['online']='da';
$_SESION['email']=$_POST['email'];
	if($_SESION['email']=="as")
echo '<meta http-equiv=refresh content="0"; url=admin.php">';
else
echo '<meta http-equiv=refresh content="0"; url=user.php">';
}}
?>

标签: phphtmlxampp

解决方案


它将解决您的问题

if( isset($_GET['actiune']) && $_GET['actiune']=="conectare") 

推荐阅读