-3

Here is the my file and code details i am using languages first one html, second is php, mysql and also i am facing implode function error if i am storing multiple check box value then show error how to fix this error and also undefined error showing

In This Type Of Error Generate After Clicking Submit Button But Data Store Successfully in my data base but its showing warning if i am not filling this field

and if i am validating form filed required then submit button not working if i am doing No Validate then successfully working my submit button

here is my database image

enter image description here

// Store data based on option type
if ($property_cat == "Residential") {
    // Resiidential Value Insert
     $property_looking = $_POST['property_looking'];
     $property_cat = $_POST["property_cat"];
     $property_sub_type = $_POST['property_sub_type'];
     $R_city = $_POST['R_city'];
     $R_Locality = $_POST['R_Locality'];
     $R_society = $_POST['R_society'];
     $R_H_number = $_POST['R_H_number'];
     $R_Bedroom = $_POST['R_Bedroom'];
     $R_Bathroom = $_POST['R_Bathroom'];
     $R_Balcony = $_POST['R_Balcony'];
     $R_Sup_Build = $_POST['R_Sup_Build'];
     $R_Super_Build_Meas_unit = $_POST['R_Super_Build_Meas_unit'];
     $R_Carpet = $_POST['R_Carpet'];
     $R_Carpet_Meas_unit = $_POST['R_Carpet_Meas_unit'];
     //$otherrooms = $_POST['otherrooms'];
     //$R_Other_Rooms= implode(',',$_POST['R_Other_Rooms']);
     $R_Other_Rooms = isset($_POST["R_Other_Rooms"]) ? $_POST["R_Other_Rooms"] : 'Not Available';
     //$R_Other_Rooms =implode(',', $R_Other_Rooms);
     $R_Furnished = $_POST['R_Furnished'];
     $R_R_Parking = $_POST['R_R_Parking'];
     $R_O_Parking = $_POST['R_O_Parking'];
     $R_Ready_to_Moove = $_POST['R_Ready_to_Moove'];
     $R_Pro_Age = $_POST['R_Pro_Age'];
     $R_possession = $_POST['R_possession'];
     $R_Prop_Images = implode(',', $_POST['R_Prop_Images']);
     move_uploaded_file($temp_name,"../property_images/$R_Prop_Images");
     $R_Owner_Type = $_POST['R_Owner_Type'];
     //$property_features = implode(',', $_POST['property_features']);
     $R_Exp_Price = $_POST['R_Exp_Price'];
     //$expectedprice = str_replace(',', '', $expectedprice);
    // $expectedprice = str_replace('₹', '', $expectedprice);
     $R_Per_Squr_Price = $_POST['R_Per_Squr_Price'];`

Warning: Undefined array key "R_possession" in C:\xampp\htdocs\key\include\listing_store.php on line 32

Warning: Undefined array key "R_Brokerage_Nego" in C:\xampp\htdocs\key\include\listing_store.php on line 48

Warning: Undefined array key "R_Prop_Images" in C:\xampp\htdocs\key\include\listing_store.php on line 57

Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\key\include\listing_store.php on line 57

Warning: foreach() argument must be of type array|object, null given in C:\xampp\htdocs\key\include\listing_store.php on line 57

Warning: Array to string conversion in C:\xampp\htdocs\key\include\listing_store.php on line 67

Warning: Undefined variable $R_Prop_Images in C:\xampp\htdocs\key\include\listing_store.php on line 67 Data stored successfully`

ADyson
  • 57,178
  • 14
  • 51
  • 63
  • 2
    Are these check-boxes? You didn't show your form so it's difficult to know. If they are, I believe they don't come across in `$_POST` if they are not checked, so you need to see if they exist before using them. – droopsnoot Aug 18 '23 at 11:33
  • 1
    If `R_Prop_Images` is supposed to be an array of images that the user uploads, their information will be in `$_FILE` rather than `$_POST`, surely? If there are multiple filenames, does imploding them into a single string with comma-separation really make a suitable filename? What is in `$temp_name`? – droopsnoot Aug 18 '23 at 11:36
  • 1
    If I'm counting correctly, you didn't post line 67 on here. For help with warnings it would be easier if you could make it clear which line they refer to, especially with extracts of code where we can't count from the start. – droopsnoot Aug 18 '23 at 11:39
  • actually i have condition if user not check box check then automatically store null value and if user check box check then checkbox value store i want this but its not working in this type its generating warning – Sagar Solanki Aug 18 '23 at 11:44
  • 1
    We can't tell which of those entries in $_POST you are accessing there are supposed to come from checkboxes, and which from something else. A not checked checkbox however does not create an entry in the form submission data set in the first place. So you will need to _check_ if these entries exist, _before_ you try to access them. For anything else about this topic, which has been discussed countless times already, please see the duplicate. – CBroe Aug 18 '23 at 12:01

0 Answers0