I made some changes to the script and it is generating two errors:
What was done: I just added a select to save the data in the database. The script:
if(!empty($_GET['codusuario']) && $_SERVER['REQUEST_METHOD'] == 'GET'){
$stm = $pdo->prepare('SELECT * FROM usuario WHERE codusuario = ?');
$stm->bindParam(1, $_GET['codusuario'], PDO::PARAM_INT);
$stm->execute() or die(implode('', $pdo->errorInfo()));
$_POST = $stm->fetch(PDO::FETCH_ASSOC);
}
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if(empty($_POST['codusuario'])){
$sql = 'INSERT INTO usuario (email,senha,chave,select2,pergunta) VALUES (?, ?, ?, ?, ?)'; //email, senha, chave, pergunta
$stm = $pdo->prepare($sql);
$stm->bindParam(1, $_POST['email']);
$stm->bindParam(2, $_POST['senha']);
$stm->bindParam(3, $_POST['chave']);
$stm->bindParam(4, $_POST['select2']); //@new select box
$stm->bindParam(5, $_POST['pergunta']);
$stm->execute();
} else {
$sql = 'UPDATE usuario SET email = ?, senha = ?, chave = ?, pergunta = ? WHERE codusuario = ?';
$stm = $pdo->prepare($sql);
$stm->bindParam(1, $_POST['email']);
$stm->bindParam(2, $_POST['senha']);
$stm->bindParam(3, $_POST['chave']);
$stm->bindParam(4, $_POST['pergunta']);
$stm->bindParam(5, $_POST['codusuario'], PDO::PARAM_INT); //old number is 5
$stm->bindParam(6, $_POST['select2']);
$stm->execute();
}
header('Location: index.php');
exit;
}