php - 用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">';
}}
?>
解决方案
它将解决您的问题
if( isset($_GET['actiune']) && $_GET['actiune']=="conectare")
推荐阅读
- python - 在 Python 中删除文件
- r - 来自 Web 可访问文件夹的 List.files
- php - MySQL ORDER BY Datetime 适用于 PHPMyAdmin 但不适用于 PHP
- angular - ng build 不会将箭头函数转换为 es5
- java - spring boot 多模块配置
- selenium - 如何使用 Katalon Studio 通过 Selenium 在子 WebElements 列表中找到具有“checked”属性的 webelement
- ruby - File.readlines($file)[z] 在红宝石中是什么意思?
- vsto - 如果 Outlook 插件定义的某些规则被破坏,如何防止保存 Outlook.AppointmentItem
- windows - 在 powershell 中生成 RSA 密钥对
- batch-file - 预定蝙蝠的净使用