我尝试使用phpmyadmin执行CRUD操作 当我选择编辑选项后,我得到错误,我尝试但没有得到它
我在编辑操作中遇到以下错误
注意:未定义的索引:在C:\ wamp \ www \ projects \ edit.php中编辑 3
(!)注意:未定义的变量:C:\ wamp \ www \ projects \ edit.php中的id 第23行调用堆栈#TimeMemoryFunctionLocation 10.0010252672 {main}( ).. \ edit.php:0"方法="后"> name =
password =
email =
注意:未定义索引:C:\ wamp \ www \ projects \ edit.php中的edit_form 第39行
-- Table structure for table `user`
警告:无法修改标头信息 - 已发送的标头 (输出从C:\ wamp \ www \ projects \ edit.php:26开始) 第46行的C:\ wamp \ www \ projects \ edit.php
CREATE TABLE IF NOT EXISTS `user` (
`userid` varchar(50) NOT NULL,
`name` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`pass` varchar(50) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `email_2` (`email`),
UNIQUE KEY `email_3` (`email`),
UNIQUE KEY `userid` (`userid`),
UNIQUE KEY `email_4` (`email`),
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=66 ;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`userid`, `name`, `email`, `pass`, `timestamp`, `id`) VALUES
('59e3950737b1f', 'ram', 'ram@gmail.com', 'rampwd', '2017-10-15 17:04:07', 59),
('59e3a5d94dfbd', 'gaurang', 'gnt3131@gmail.com', 'gaurangpwd', '2017-10-15 18:15:53', 64);
index.php
<html>
<head>
<title></title>
</head>
<body>
<center>
<h1> ADD USER</H1>
<form action="index.php" method="post">
name=<input type ="text" name="name"required/></br>
password=<input type ="text" name="pass" requierd /></br>
email=<input type ="text" name="email" required /></br></BR>
<input type ="submit" name="submit" VALUE ="INSERT"/></br>
</form>
</center>
<?php
$connection=mysqli_connect('localhost','root','root','crud');
if(isset($_POST['submit'])){
$name = $_POST['name'];
$email = $_POST['email'];
$pass = $_POST['pass'];
$userid=uniqid();
if(mysqli_query($connection,"insert into user(userid,name,email,pass)values('$userid','$name','$email','$pass')"))
{
echo"<H2>succesfully insert query</H2>";
}
}
?>
<div align="center">
<table border="2" width="600">
<tr>
<th>USERID</th>
<th>NAME</th>
<th>EMAIL</th>
<th>PASSWORD</th>
<th>DATE CREATED </th>
<th>EDIT</th>
<th>DELETE</th>
</tr></div>
<?php
$connection=mysqli_connect('localhost','root','root','crud');
if(isset($_REQUEST['del'])){
$del_id= $_REQUEST['del'];
if(mysqli_query($connection,"delete from user where id =$del_id"))
{
echo"<h2>selected user of is deleted succesfully";
}
}
$run=mysqli_query($connection,"select * from user");
while($row=mysqli_fetch_array($run))
{
$showuserid=$row[0];
$showname=$row[1];
$showemail=$row[2];
$showpass=$row[3];
$showdate=$row[4];
$showid=$row[5];
echo"<tr>
<td>$showuserid</td>
<td>$showname</td>
<td>$showemail</td>
<td>$showpass</td>
<td>$showdate</td>
<td><a href='edit.php?edit=$showid'>EDIT</td>
<td><a href='?del=$showid'>DELETE</td>
</tr>
";
}
?>
</body>
</html>
-------------------------
edit.php
<?php
$connection=mysqli_connect('localhost','root','root','crud');
$edit=$_REQUEST['edit'];
$run=mysqli_query($connection,"select * from user where id = '$edit'");
while($row=mysqli_fetch_array($run))
{
$name=$row[1];
$email=$row[2];
$pass=$row[3];
$id=$row[5];
}
?>
<html>
<body>
<center>
<h1> EDIT USER</H1>
<form action="edit.php?edit_form =<?php echo $id ?>" method="post">
name=<input type ="text" name="uname" value="<?php echo $name ?>"/></br>
password=<input type ="text" name="upass" value="<?php echo $pass ?>" /></br>
email=<input type ="text" name="uemail" value="<?php echo $email ?>" /></br> </BR>
<input type ="submit" name="uedit" VALUE ="Edit"/></br>
</form>
</center>
</body>
</html>
<?php
$connection=mysqli_connect('localhost','root','root','crud');
if(isset($_POST['uedit']))
{
$uid= $_REQUEST['edit_form'];
$uname= $_POST['uname'];
$upass= $_POST['upass'];
$uemail= $_POST['uemail'];
if(mysqli_query($connection,"update user set name='$uname',email='$uemail',pass='$upass' where id='$uid' "))
{
header("location:index.php");
}
}
----
答案 0 :(得分:0)
在你的edit.php文件中,将action =“edit.php?edit_form =”改为action =“”并添加输入类型=“隐藏”name =“id”value =“'。$ id。'”;进入你的形式如下......
.truckIcon{
background-image: url(../images/icons/favicon.png);
background-repeat: no-repeat !important;
width:80px;
height:80px;
display: inline-block;
}
答案 1 :(得分:-1)
检查此行中的index.php:
<td><a href='edit.php?edit=$showid'>EDIT</td>
可能会发生两件事
第一: - $ showid为空,当您点击编辑按钮时,它会发送一个空值。
或第二: - 在edit.php中检查以下行:
$run=mysqli_query($connection,"select * from user where id = '$edit'");
像这样改变
$run=mysqli_query($connection,"select * from user where id = '".$_GET['edit']."'");