Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.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,存在国家/地区字段所在的注册表。如果用户的国家/地区不在下拉列表中。用户可以选择其他,此时显示一个文本框,用户在文本框中输入自己的国家。按用户提交国家后。如何批准请求的国家并在php中发布国家下拉列表 config.php <?php $con=mysql_connect("localhost","root",""); if(!$con) { die("Could not connect".mysql_error()); } mysql_select_db("RateMyProfe

存在国家/地区字段所在的注册表。如果用户的国家/地区不在下拉列表中。用户可以选择其他,此时显示一个文本框,用户在文本框中输入自己的国家。按用户提交国家后。如何批准请求的国家并在php中发布国家下拉列表

config.php

<?php
$con=mysql_connect("localhost","root","");
if(!$con)
{
    die("Could not connect".mysql_error());
}
mysql_select_db("RateMyProfessor",$con);

?>
 <?php 

include ("config.php");
$query = "select * from user_details where is_approved='0'";

$result=mysql_query($query);

$i = 1; //counter for the checkboxes so that each has a unique name
echo "<form action='process.php' method='post'>"; //form started here
echo "<table border='1'>
<tr>
<th>UserId</th>
<th>Email</th>
<th>Country </th>
<th>Update</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['UserId'] . "</td>";
  echo "<td>" . $row['Email'] . "</td>";
  echo "<td>" . $row['Country'] . "</td>";

  echo "<td><input type='checkbox' name='check[$i]' value='".$row['UserId']."'/>";   
  echo "</tr>";
  $i++;
  }
echo "</table>";
echo "<input type='submit' name='approve' value='approve'/>";
echo "</form>";

mysql_close($con);
?>
<?php
include_once("config.php");
if(isset($_POST['approve']))
{
        if(isset($_POST['check']))
        {
                    foreach ($_POST['check'] as $value){
                        echo $value;
                        $sql = "update user_details set is_approved ='1' where UserId = '$value'"; 

                        mysql_query($sql) or die (mysql_error());

                    }
        }
}
?>          

Demo.php

<?php
$con=mysql_connect("localhost","root","");
if(!$con)
{
    die("Could not connect".mysql_error());
}
mysql_select_db("RateMyProfessor",$con);

?>
 <?php 

include ("config.php");
$query = "select * from user_details where is_approved='0'";

$result=mysql_query($query);

$i = 1; //counter for the checkboxes so that each has a unique name
echo "<form action='process.php' method='post'>"; //form started here
echo "<table border='1'>
<tr>
<th>UserId</th>
<th>Email</th>
<th>Country </th>
<th>Update</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['UserId'] . "</td>";
  echo "<td>" . $row['Email'] . "</td>";
  echo "<td>" . $row['Country'] . "</td>";

  echo "<td><input type='checkbox' name='check[$i]' value='".$row['UserId']."'/>";   
  echo "</tr>";
  $i++;
  }
echo "</table>";
echo "<input type='submit' name='approve' value='approve'/>";
echo "</form>";

mysql_close($con);
?>
<?php
include_once("config.php");
if(isset($_POST['approve']))
{
        if(isset($_POST['check']))
        {
                    foreach ($_POST['check'] as $value){
                        echo $value;
                        $sql = "update user_details set is_approved ='1' where UserId = '$value'"; 

                        mysql_query($sql) or die (mysql_error());

                    }
        }
}
?>          

您可以在批准时在国家/地区表中插入新记录
例如