<?php
error_reporting(0);
require 'conn.php';
global $conn;
$tablename = $_SESSION['user_id']."_LIETOTAJU_ATIBLDES";
$sql = "CREATE TABLE ".$tablename." (
id INT NOT NULL AUTO_INCREMENT,
ATBILDE varchar(255),
PATIES varchar(255),
PRIMARY KEY (id)
)";
if (mysqli_query($conn, $sql)) {
} else {
}
$val = $_GET['QUESTONS'];
mysqli_set_charset($conn,"utf8");
$sql = "SELECT * FROM Jautajumi_Prof where TEMAS_NOSAUKUMS = ? ";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)){
header ('location: test.php?error');
exit();
}else{
mysqli_stmt_bind_param($stmt, "s", $val);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
}
$sum = 0;
$one = 1;
$sum = $sum + $one;
while ($row = mysqli_fetch_assoc($result)){
echo "
<form class='test_place' action='answer.inc.php?QUESTONS=".$_GET['QUESTONS']."' method='post'>
<h4>". $sum = $sum + $one .". ".$row["JAUTAJUMS"]."</h4>
<input type='checkbox' class='testplace' name='check_list[]' value='".$row["ATBILDE_A"]."' >
<label>".$row["ATBILDE_A"]."</label>
<input type='checkbox' name='check_list[]' value='".$row["ATBILDE_B"]."'>
<label>".$row["ATBILDE_B"]."</label>
<input type='checkbox' name='check_list[]' value='".$row["ATBILDE_C"]."'>
<label>".$row["ATBILDE_C"]."</label>
<input type='checkbox' name='check_list[]' value='".$row["ATBILDE_D"]."'>
<label>".$row["ATBILDE_D"]."</label>
<form>
";
}
?>
<div class='iesniegt'>
<form method='post' action='answer.inc.php'>
<input name='iesniegt' type='submit' id='iesniegt' value='Iesniegt'>
</form>
</div>
All works except databse wont delete it!!!
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
if (isset($_POST['delete_account'])){
require 'conn.php';
global $conn;
$password = $_POST['delete_password'];
$email = 'delete@gmail.com';
$user_id = '5';
$sql = "SELECT * FROM user_acounts WHERE e_pasts=?;";
$stmt = mysqli_stmt_init($conn); // Inicializcija
if(!mysqli_stmt_prepare($stmt, $sql)){
header ('location: userpanel.php?error');
exit();
}else{
mysqli_stmt_bind_param($stmt, "s", $email);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
}
if ($row = mysqli_fetch_assoc($result)){
$password_check = password_verify($password, $row["PAROLE"]);
if ($password_check == false){
header ('location:userpanel.php?password=false');
exit();
}else if ($password_check == true){
$SQL = "DELETE FROM user_acounts WHERE e_pasts=?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql))
{
header('location: userpanel.php?error');
exit();
}
else
{
mysqli_stmt_bind_param($stmt, "s", $email);
mysqli_stmt_execute($stmt);
header('location: userpanel.php?delete=true');
exit();
}
}
}
mysqli_stmt_close($stmt);
mysqli_close($conn);
}
?>
I am making a thing that user can delete his account so evrebody works except delete form...