我在我的网站上运行此代码
if($_GET['approve']) {
$tmppass = randomPassword();
$dbpass = md5('nosaltforyou'.md5($tmppass).'nosaltforyou');
$conn = mysqli_connect("localhost", "php", "password", "icegc");
$row = mysqli_query($conn, "SELECT * FROM `applications` WHERE `id` = ".$_GET['approve']);
mysqli_query($conn, "INSERT INTO `users` VALUES (null, '".$row['nickname']."','$dbpass','".$row['steamlink']."','".$row['tmplink']."','".$row['icevtc']."','".$row['csgo']."','member'");
mysqli_query($conn, "DELETE FROM `applications` WHERE `id` = ".$_GET['approve']);
echo '<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Warning!</strong> Send This Password: '.$tmppass.' To <a href="'.$row['steamlink'].'" class="alert-link">This Steam Profile</a>
</div>';
mysqli_close($conn);
}
以及应该做的是通过将应用程序添加到我的users表并从我的应用程序表中删除它来批准加入该站点的应用程序。我没有在数据库中得到任何改变,也没有输出到网页。任何和所有的帮助表示赞赏。提前致谢。
答案 0 :(得分:0)
我没办法测试它,但试试这个:
<?php
if(isset($_GET['approve'])){
try {
$tmppass = randomPassword();
$dbpass = md5('nosaltforyou'.md5($tmppass).'nosaltforyou');
$mysqli = new mysqli("localhost", "php", "password", "icegc");
if($stmt = $mysqli->prepare("SELECT * FROM `applications` WHERE `id`=?")){
$stmt->bind_param('i', intval($_GET['approve']));
$stmt->execute();
$result = $stmt->get_result();
}
if($mysqli->errno){
throw new Exception('MySQL error: '.$mysqli->error);
}
while($row = $result->fetch_array()){
$steamlink = $row['steamlink'];
if($stmt = $mysqli->prepare("INSERT INTO `users` VALUES (null, ?, ?, ?, ?, ?, ?, ?)")){
$stmt->bind_param('sssssss', $row['nickname'], $dbpass, $steamlink, $row['tmplink'], $row['icevtc'], $row['csgo'], 'member');
$stmt->execute();
}
if($mysqli->errno){
throw new Exception('MySQL error: '.$mysqli->error);
}
if($stmt = $mysqli->prepare("DELETE FROM `applications` WHERE `id`=?")){
$stmt->bind_param('i', intval($_GET['approve']));
$stmt->execute();
}
if($mysqli->errno){
throw new Exception('MySQL error: '.$mysqli->error);
}
}
echo '<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Warning!</strong> Send This Password: '.$tmppass.' To <a href="'.$steamlink.'" class="alert-link">This Steam Profile</a>
</div>';
$mysqli->close();
} catch(Exception $e){
echo $e->getMessage();
}
}
?>