我正在根據管理員輸入創建激活/停用。 這個想法是允許管理員從帳戶表中查看所有帳戶,並使用無線電輸入從選擇(激活或停用)中選擇一個帳戶。 我真的很感激,如果你們可以幫助我在這個網頁上,我的項目幾乎完成。 謝謝所有您的建議,我只是想讓管理員可以選擇激活或停用用戶帳戶,使用此代碼。 該代碼基本上查看帳戶的所有信息,管理員只是複選框,她想激活任何人,並從無線電選擇(激活/停用),並根據她的輸入將設置數據庫中的值爲0,這是停用和1激活。 謝謝PHP/HTML:通過管理頁面使用單選按鈕激活用戶
<?php
session_start();
if(isset($_SESSION['username'])){
//Connect to DB
//include_once("Project/CIEconn.php");
$mysqlCON= mysqli_connect("localhost", "root", "","CIE") or die(mysqli_connect_error());
mysqli_select_db($mysqlCON,'CIE') or die ("no database");
if(isset($_POST['ActivateUsers'])){
if(empty($_POST['Id']) || $_POST['Id'] == 0){
echo"<h4> please choose someone to activate </h4>";
}else{
$impid = implode("' , '" , $_POST['Id']);
$sqlDelete = "UPDATE Accounts SET Activated='$_POST[activate]' WHERE Id IN ('" . $impid . "')";
$DeleteQuery = mysqli_query($mysqlCON,$sqlDelete) or die ("Error : ".mysqli_error($mysqlCON));
}
}
$sqlCommand = "SELECT * FROM Accounts ";
$result = mysqli_query($mysqlCON,$sqlCommand) or die(mysql_error());
echo "<h1> Activate/Deactive User Account </h1>";
echo "<table border='1' width = 80% align=center >
<tr>
<th>Check </th>
<th>SSU ID</th>
<th>Email</th>
<th>First Name</th>
<th>Last Name</th>
<th>User Type </th>
<th>Activated</th>
<th>Activate/Deactive</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<form action='ActivateD.php' method='post'>";
echo "<td> <input type='checkbox' name='Id[]' value='". $row['SSU'] ."' /> </td> " ;
echo "<td align=center > " . $row['SSU'] . "</td>";
echo "<td align=center>" . $row['Email'] . "</td>";
echo "<td align=center>" . $row['First_Name'] . "</td>";
echo "<td align=center>" . $row['Last_Name'] . "</td>";
echo "<td align=center>" . $row['userType'] . "</td>";
echo "<td align=center>" . $row['Activated'] . "</td>";
echo "<td align=center>" .
"
<input type='radio' name='activate' value='1' > Activate
<input type='radio' name='activate' value='0'> Deactive
</form>"
. "</td>";
echo "</tr> ";
}
echo "</table>";
echo " <br>
<form action='ActivateD.php' method='post'>
<div align='center'>
<input type='submit' name='ActivateUsers' value='Activate/Deactive'>
</div>
</form>";
mysqli_close($mysqlCON);
}
else{echo "must logout to see this page..!!";}
?>
<html>
<head><title> Activate/Deactive User Account </title>
<style type="text/css">
body{
background-color: #23438e;
}
table{
background: white;
}
h1{
color: #FF942B;
text-align: center;
padding-top : 50px;
text-decoration: none;
}
</style>
</head>
<body>
</body>
</html>
請問您可以編輯您的問題以包含更多信息?諸如代碼做什麼或不做什麼(以及你嘗試過的)等事情都可以讓某人提供更好的幫助。 – cokeman19
謝謝,我只是添加了一些信息到我的文章 – AAaaAA