Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.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 - Fatal编程技术网

Php 访问$邮政 医生

Php 访问$邮政 医生,php,Php,$\u POST是一个全球性的,或者更确切地说是“超级全球性的”。它应该可以在脚本中的任何位置访问,包括条件语句、函数和类内部 您确定设置了$\u POST['sub6']吗 另一方面,请不要这样做: <?php session_start(); if(isset($_SESSION['s1'])) { $uname=$_SESSION['s2']; echo "<b><i>hello ".$_SESSION['s1']; echo "</b></

$\u POST是一个全球性的,或者更确切地说是“超级全球性的”。它应该可以在脚本中的任何位置访问,包括条件语句、函数和类内部

您确定设置了$\u POST['sub6']吗

另一方面,请不要这样做:

<?php
session_start();
if(isset($_SESSION['s1']))
{
$uname=$_SESSION['s2'];
echo "<b><i>hello ".$_SESSION['s1'];
echo "</b></i>";

}
else{
$name="none";
}
?>
<html>
<head>
<title>Doctor</title>
<form method="post">
<?php

$connection=Mysql_connect('localhost','admin','123');
Mysql_select_db('db',$connection);
//agar patient list ro khast

if(array_key_exists('sub3',$_POST))
{                      

                if(!$connection)
                {
                        echo 'connection is invalid';
                }
                else
                {

                        $query="select * from pnt";
                        $result=mysql_query($query);
                        $num=Mysql_num_rows($result);
                        $num1=Mysql_num_fields($result);

                if($num>0)
                {
                echo "<table border=0>";
                echo"<tr>";
                echo"<td>ID</td><td>Name</td><td>Family</td><td>File</td>";
                echo"</tr>";
                for($i=0;$i<$num;$i++)
                {
                $row=mysql_fetch_row($result);

                for($j=0;$j<$num1;$j++)
                {
                echo"<td>$row[$j]</td>";       
                }
                echo"<td><input type='submit' name='sub6' value='$row[0]'/></td>
                <td><img src='file.jpg' width='50' height='50' /></td>";
                echo"</tr>";
                }//for

                echo"</table>";
                }//if

                }//else

exit();
}
//agar zado clinical filo khast
if(array_key_exists('sub6',$_POST))
{

$query1="select * from patient where id=".$_POST['sub6'];
$result1=mysql_query($query1);

$num2=Mysql_num_rows($result1);
$num3=Mysql_num_fields($result1);
                if($num2>0)
                {
                echo "<table border=2>";
                for($i=0;$i<$num2;$i++)
                {
                $row=mysql_fetch_row($result1);


                echo"<td>id</td><td>name</td><td>Lastname</td><td>Info</td><td>Sympthoms</td><td>Diagnosis</td>";
                echo "<tr>";
                for($j=0;$j<$num3;$j++)
                {
                echo"<td>$row[$j]</td>";       
                }
                echo"</tr>";
                }//for
                echo"</table>";
                }//if
                        $query2="select * from pharmacies";
                        $result2=mysql_query($query2);
                        $nump=Mysql_num_rows($result2);

echo "Please Select a Pharmacy:<select ID=2 name='ph'>";
echo"<option >select please";
for($i=0;$i<$nump;$i++)
{
$row=mysql_fetch_row($result2);
echo"<option value=$row[1]>$row[1]";
echo"</option>";
}
echo"</SELECT>";       
$query2="select * from pharmacy";
$result2=mysql_query($query2);
$nump=Mysql_num_rows($result2);

echo "Please Select Drug:<select ID=1 name='dg'>";
echo"<option >select please";
for($i=0;$i<$nump;$i++)
{
$row=mysql_fetch_row($result2);
echo"<option  >$row[0]";
echo"</option>";
}
echo"</SELECT>";       
echo"<input type='submit' name='insert' value='insert this drug'/>";
echo"<b>Quantity:<input type='text' name='txt1'/>";
exit();
}//if
if(array_key_exists('insert',$_POST))
{
$qname="select * from pnt where id=".$_POST['sub6'];
$resname=mysql_query($qname);
$rown=mysql_fetch_row($resname);
$na=$rown[1];
$ins="insert into request(drug,qty,ph,situation,Doctor,userp)values('".$_POST['dg']."',".$_POST['txt1'].",'".$_POST['ph']."','underprocess','$uname','$na')";
echo $ins;
$rlt=mysql_query($ins);
if (!$rlt)
{
print(mysql_errno() .":". mysql_error());
}
}

if(array_key_exists('insert',$_POST))
{
$in="select * from request";
$rslt=mysql_query($in);
if (!$rslt)
{
print(mysql_errno() .":". mysql_error());
}

$num2=Mysql_num_rows($rslt);
$num3=Mysql_num_fields($rslt);
                if($num2>0)
                {
                echo "<table border=2>";
                echo"<td>id</td><td>drug</td><td>quantity</td><td>Doctor</td><td>explanation</td><td>pharmacy</td>";
                for($i=0;$i<$num2;$i++)
                {
                $row=mysql_fetch_row($rslt);

                echo "<tr>";
                for($j=0;$j<$num3;$j++)
                {
                echo"<td>$row[$j]</td>";       
                }
                echo"</tr>";
                }//for
                echo"</table>";
                }//if
}
if(array_key_exists('sub4',$_POST))
{
header("location:login.php");
}
?>
<input type="submit" name="sub3" value="patient list"/>
<input type="submit" name="sub4" value="sign out"/>
<img src="Doc.jpg" />
</form>
</head>
</html>

php脚本中最常见的漏洞之一是从$\u POST分配值,而不对其进行筛选以获得正确的值

只有当“插入”是POST中的键时,才能输入此条件。 然后,您尝试使用“sub6”进行查询,这可能未设置。
在查询中使用它之前,您只需测试“sub6”是否存在(就像$\u POST的其余键一样)

“我没有访问$\u POST['sub6']的权限,因为它只是在数组中$\u key\u exists('sub6',$\u POST')没有任何意义。
$\u POST['sub6']
显然是空的。检查用于发布到此页面的代码,并确保发送的数据正确
array\u key\u exists
可能会说
$\u POST['sub6']
exists,但这并不意味着它有价值。而且,看在上帝的份上,SQL注入!没有@Negin,尝试发布打印结果($\u POST)。这会给我们更多的合作机会。不要在SQL查询中直接使用
$\u POST
变量。转义这些值。使用or。好的,我会过滤它,但这里有一个错误:未定义的索引:sub6在D:\phpweb\Doctor.php的第124行我不明白你的意思。你的意思是我必须使用if(array_key_exists(..))来表示sub6?何处?此处:如果(数组\键\存在('insert',$\ POST))。。。。替换为:if(array_key_存在('insert',$_POST)&&array_key_存在('sub6',$_POST))。。。。但如果使用“dg”、“txt1”或其他未经测试的VAR,则可能会出现其他问题。基本上,如果你不确定的话,就不要认为VAR已经设置(发布)了。正如其他海报所说,使用mysql\u real\u escape\u string()。我使用了你的解决方案,一次甚至不使用if语句。你是对的,非常感谢,但我现在如何更正它?它没有错误,但我如何强制它转到if?除非所有条件都为真,否则你不能强制输入if语句。在您当前的代码中,当设置了“insert”时,似乎没有设置“sub6”。如果收到数据时未设置“sub6”,则无法进行插入查询。
$qname="select * from pnt where id=".$_POST['sub6'];