通过php中的管理员批准提交的数据


Approve submitted data by admin in php

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

config.php

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

Demo.php

 <?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);
?>

process.php

<?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());
                    }
        }
}
?>          

当管理员从管理员端批准国家时,国家是国家表上的副本。

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

<?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());
                        $sql = "select other_country from user_details where UserId = '$value'"; 
                        $result = mysql_query($sql) or die (mysql_error());

                         if($Other_country_name = mysql_fetch_assoc($result))
                         {
                              $Other_country_name = $Other_country_name['other_country'];
                         }

                        $sql = "insert into country_table set name = '$Other_country_name'";
                        mysql_query($sql) or die (mysql_error());
                    }
        }
}
?>     

我没有执行条件。请自己做