Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当删除页面未删除时,如何修复该页面_Php_Mysql - Fatal编程技术网

Php 当删除页面未删除时,如何修复该页面

Php 当删除页面未删除时,如何修复该页面,php,mysql,Php,Mysql,“我的删除”页面尚未删除,但它会显示一条成功消息。但它也会显示一个id错误,如下所示: 注意:第3行C:\wamp\www\Potifolio\delete.php中未定义的索引:player\u id 已成功删除记录: 文件:display.php 文件:delete.php 您正在混合PHP$\u GET和$\u POST定义。检查此问题,因为它包含您问题的完整答案。请输入包含删除记录元素的表单html。如果您没有发布到删除脚本中,您将获得它。你应该检查一下你是否有一个$\u POST[

“我的删除”页面尚未删除,但它会显示一条成功消息。但它也会显示一个id错误,如下所示:

注意:第3行C:\wamp\www\Potifolio\delete.php中未定义的索引:player\u id

已成功删除记录:

文件:display.php

文件:delete.php
您正在混合PHP
$\u GET
$\u POST
定义。检查此问题,因为它包含您问题的完整答案。

请输入包含删除记录元素的表单html。如果您没有发布到删除脚本中,您将获得它。你应该检查一下你是否有一个
$\u POST['player\u id']
@PhillSparks它让你成为了一个明星真正的明星你应该逃避
$player\u id
-目前你的删除脚本中有一个SQL注入漏洞。谢谢我从Phill那里得到了它,但是现在我如何用是或否选项来实现它呢?为了使用户不犯错误,您必须使用Javascript创建删除确认对话框。谷歌搜索它或者在stackoverflow上搜索这里,我相信你会找到很多例子。好吧,但有一天我用普通php做了,它无法弹出,但我可以带我到两个链接是或否
<?php
#connect to the database
include_once('connect.php');

$strSQL = "SELECT * FROM players";

// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);

// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array

echo "
    <table border='1' >
        <tr bgcolor='#cccccc'>
            <td>Name</td>
            <td>Surname</td>
            <td>Contact Number</td>
            <td>Email</td>
            <td>Position</td>
            <td>User Nmae</td>
            <td>Password</td>
            <td colspan='2'>Action</td>
        </tr>
";

while($row = mysql_fetch_array($rs)) {
    $player_id =  $row['player_id'];
    $name =  $row['name'];
    $surname =  $row['surname'];
    $contact_number =  $row['contact_number'];
    $email =  $row['email'];
    $position =  $row['position'];
    $username =  $row['username'];
    $password =  $row['password'];
    $surname = mysql_real_escape_string($surname);
    $name = mysql_real_escape_string($name);
    $email = mysql_real_escape_string($email);
    $position = mysql_real_escape_string($position);
    $username = mysql_real_escape_string($username);
    $password = mysql_real_escape_string($password);

    echo "
        <tr bgcolor='#cccccc'>
            <td>$name</td>
            <td>$surname</td>
            <td>$contact_number</td>
            <td>$email</td>
            <td>$position</td>
            <td>$username</td>
            <td>$password</td>
            <td><a href='edit.php?player_id=$player_id'>Edit</a></td>
            <td><a href='delete.php?player_id=$player_id'>Delete</a></td>
        </tr>
    ";
}

echo'</table>';
?>
<?php 
include_once("connect.php");
$player_id = $_POST['player_id'];
$delete= "DELETE FROM players WHERE player_id = '$player_id'";
$result = mysql_query($delete);

if($result){
    echo "Record deleted successfuly ";
}else{
    echo "No data deleted";
}
?>