I hosted my website and then suddenly the php command for inserting a record into the database doesn't work.
Here is the code of the command, the success message works but the record isn't inserted in the database. When I run the website locally, it works fine. Some of the commands of my website are working in terms of being able to insert into the database, but some are just like this problem, the success message is working but the database doesn't change
function doInsert(){
global $mydb;
if(isset($_POST['save'])){
if ($_POST['U_NAME'] == "" OR $_POST['U_USERNAME'] == "" OR $_POST['U_PASS'] == "") {
$messageStats = false;
message("All field is required!","error");
redirect('index.php?view=add');
}else{
$sql = "SELECT * FROM useraccounts WHERE ACCOUNT_USERNAME='" .$_POST['U_USERNAME']."'";
$mydb->setQuery($sql);
$userresult = $mydb->loadSingleResult();
if ($userresult) {
# code...
message("Username is already taken.", "error");
redirect('index.php?view=add');
}else{
$user = New User();
$user->USERID = $_POST['user_id'];
$user->ACCOUNT_NAME = $_POST['U_NAME'];
$user->ACCOUNT_USERNAME = $_POST['U_USERNAME'];
$user->ACCOUNT_PASSWORD =sha1($_POST['U_PASS']);
$user->ACCOUNT_TYPE = $_POST['U_ROLE'];
$user->create();
message("New [". $_POST['U_NAME'] ."] created successfully!", "success");
redirect("index.php");
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire