I have a page with a popup, in that popup is a form and in that form I want to send the info to another page for processing and submission into my database. Right now my database gets filled with blank spaces where there should be a form variable, date and photo are the only two that insert correct variables. This is my popup form.
<div id="photo_form">
<form id="photo_form" enctype="multipart/form-data" method="post" action="photo_system2.php">
<input type="hidden" id="city" value="<?php echo $city; ?>">
<input type="hidden" id="region" value="<?php echo $region; ?>">
<input type="hidden" id="country" value="<?php echo $country; ?>">
<input type="hidden" id="latitude" value="<?php echo $latitude; ?>">
<input type="hidden" id="longitude" value="<?php echo $longitude; ?>">
<textarea id="message" required type="text" placeholder=" enter message here:" onkeyup="restrict('email')" maxlength="300" style="height: 200px; width: 400px;"></textarea>
<input id="name" required type="text" placeholder=" enter name:" onkeyup="restrict('email')" maxlength="50" style="width: 200px;">
<input id="email" required type="email" placeholder=" enter email address:" onkeyup="restrict('email')" maxlength="88" style="width: 200px;">
<input id="phone" placeholder=" phone number (optional):" onkeyup="restrict('email')" maxlength="88" style="width: 200px;">
<input type="file" name="photo" accept="image/*">
<br>select which subject:
<div id="inquiry">
<input checked='true' type="checkbox" id="inquiry[]" value="consult">free consultation<br>
<input type="checkbox" id="inquiry[]" value="sell">sell<br>
</div>
<input type="submit" value="submit" >
</form>
</div>
Photo_system2 looks like this
include_once("resources/init.php");
include_once("db_conx.php");
if (isset($_POST["message"]) && isset ($_POST["email"])){
$sql = "SELECT * FROM users";
$query = mysqli_query($db_conx, $sql);
$row = mysqli_fetch_row($query);
$message = $_POST["message"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$name = $_POST["name"];
$city = $_POST["city"];
$region = $_POST["region"];
$country = $_POST["country"];
$latitude = $_POST["latitude"];
$longitude = $_POST["longitude"];
$inq = $_POST['inquiry'];
if ( isset($_POST['inquiry']) ) {
$_POST['inquiry'] = implode(', ', $_POST['inquiry']);}
$_POST['inquiry'] = array();
$inq = implode(', ', (array)$inq);
$fileName = $_FILES["photo"]["name"];
$fileTmpLoc = $_FILES["photo"]["tmp_name"];
$fileType = $_FILES["photo"]["type"];
$fileSize = $_FILES["photo"]["size"];
$fileErrorMsg = $_FILES["photo"]["error"];
$kaboom = explode(".", $fileName);
$fileExt = end($kaboom);
$db_file_name = date("DMjGisY")."".rand(1000,9999).".".$fileExt; // WedFeb272120452013RAND.jpg
list($width, $height) = getimagesize($fileTmpLoc);
if($width < 10 || $height < 10){
header("location: That image has no dimensions");
exit();
}
if (!preg_match("/\.(gif|jpg|png|bmp|jpeg)$/i", $fileName) ) {
header("location: your image file was not a recognized type (jpg, gif, bmp, jpeg, or png type");
exit();
} else if ($fileErrorMsg == 1) {
header("location:An unknown error occurred");
exit();
}
$moveResult = move_uploaded_file($fileTmpLoc, "admin/photos/$db_file_name"); //edited
if ($moveResult != true) {
header("location: File upload failed");
exit();
}
include_once("image_resize.php");
$wmax = 2048;
$hmax = 2048;
if($width > $wmax || $height > $hmax){
$target_file = "admin/photos/$db_file_name"; //edited
$resized_file = "admin/photos/$db_file_name"; //edited
img_resize($target_file, $resized_file, $wmax, $hmax, $fileExt);
}
$sql = "INSERT INTO users(photo, username, message, phone, email, city, region, country, latitude, longitude, inquiry, inqdate) VALUES ('$db_file_name','$name','$message','$phone','$email','$city','$region','$country','$latitude','$longitude','$inq',now())";
$query = mysqli_query($db_conx, $sql);
mysqli_close($db_conx);
header('location: blog.php');
exit();
}
Why am I getting blank spaces in my database where there should be these posted variables?
Aucun commentaire:
Enregistrer un commentaire