登录后重定向到同一页面时第一次出现未定义索引错误,如何解决此问题?
这是我的代码:
代码
<form class="col s12" method="POST" action="{{ url('indexedit/ ' . $val->id }}" >
页面代码提交表单后
<?php
session_start();
$error = $_SESSION['error'];
$conn = mysql_connect("localhost", "root", "");
mysql_select_db("db_food", $conn);
$row = mysql_query("select * from tbl_temp order by id DESC", $conn);
$row = mysql_fetch_array($row);
$user = $row['user'];
$pass = $row['pass'];
?>
我想在索引页面中显示错误消息。
答案 0 :(得分:1)
首先按isset
$error = "";
if(isset($_SESSION['error'])){
$error = $_SESSION['error'];
}