Can not save form data to MySQL databases

inam

New member
this my code for creating a user:
Code:
    static public function ctrCreateUser(){
		if (isset($_POST["newUser"])) {
			if (preg_match('/^[a-zA-Z0-9 ]+$/', $_POST["newName"]) &&
				preg_match('/^[a-zA-Z0-9]+$/', $_POST["newUser"]) &&
				preg_match('/^[a-zA-Z0-9]+$/', $_POST["newPasswd"])){
				$photo = "";
				if (isset($_FILES["newPhoto"]["tmp_name"])){

				list($width, $height) = getimagesize($_FILES["newPhoto"]["tmp_name"]);
				$newWidth = 500;
				$newHeight = 500;
				$folder = "views/img/users/".$_POST["newUser"];
				mkdir($folder, 0755);
				if($_FILES["newPhoto"]["type"] == "image/jpeg"){
					$randomNumber = mt_rand(100,999);
					$photo = "views/img/users/".$_POST["newUser"]."/".$randomNumber.".jpg";
					
					$srcImage = imagecreatefromjpeg($_FILES["newPhoto"]["tmp_name"]);
					$destination = imagecreatetruecolor($newWidth, $newHeight);
					imagecopyresized($destination, $srcImage, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
					imagejpeg($destination, $photo);
				}
				if ($_FILES["newPhoto"]["type"] == "image/png") {

					$randomNumber = mt_rand(100,999);
					$photo = "views/img/users/".$_POST["newUser"]."/".$randomNumber.".png";
					$srcImage = imagecreatefrompng($_FILES["newPhoto"]["tmp_name"]);
					
					$destination = imagecreatetruecolor($newWidth, $newHeight);
					imagecopyresized($destination, $srcImage, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
					imagepng($destination, $photo);
				}
			}
			$table = 'users';
			$encryptpass = crypt($_POST["newPasswd"], '$2a$07$asxx54ahjppf45sd87a5a4dDDGsystemdev$');
			$data = array('name' => $_POST["newName"],
						  'user' => $_POST["newUser"],
							'password' => $encryptpass,
							'profile' => $_POST["newProfile"],
							'photo' => $photo);
			$answer = UsersModel::mdlAddUser($table, $data);
			if ($answer == 'ok') {
					......................}
                            else{
                            ..........}
		
		}
}
complete code is here
with comments thanks.
 
Last edited:
no PHP error I enable PHP_error in debugging
I test my app in chromium no problem but with compiled exe no error but no save data to msql “i think MySQL can not get data from array in exeout”
this is very short and easy: it is also not works
Code:
static public function ctrCreateCu(){
		if(isset($_POST["newCu"])){

			if(preg_match('/^[a-zA-Z0-9]+$/', $_POST["newCu"]) &&
			   preg_match('/^[()\-0-9 ]+$/', $_POST["newPhone"]) && 
			   preg_match('/^[#\.\-a-zA-Z0-9 ]+$/', $_POST["newAddress"])){

			   	$table = "cu";

			   	$data = array("name"=>$_POST["newCu"],
					           "phone"=>$_POST["newPhone"],
					           "address"=>$_POST["newAddress"];

			   	$answer = ModelCu::mdlAddCu($table, $data);

			   	if($answer == "ok"){

					....

				}

			}else{

			....

			}

		}
 
yes I test extensions but still not working please if you check my app files for problem.
 
Last edited:
Back
Top