خرید بک لینک

Vote count: 0

I have this form ,

Form image

i perosonal details will be inserted into personal table then book details into book table.

book details has 1 original and 4 cloned rows. i want to insert all them at once into database.

Earlier i had used php mysqli_real_escape_string which was working perfectly with bootstrap 3. but same is not working with materialize css. giving error Waing: Invalid argument supplied for foreach().

here is my code,

$mysqli = new mysqli($host,$user,$password,$database);

    $users_firstname = $_POST['firstname'];
    $users_middlename = $_POST['middlename'];
    $users_lastname = $_POST['lastname'];
    $users_gender= $_POST['gender'];
    $users_location= $_POST['location'];
    $users_email= $_POST['email'];
    $users_mobile= $_POST['mobile'];
    $users_message= $_POST['message'];

    $user_query = "INSERT INTO personaldetails(FirstName ,MiddleName,LastName,
    Gender,Location,Email,Mobile,Message) VALUES ('$users_firstname',
    '$users_middlename', '$users_lastname', '$users_gender','$users_location','$users_email','$users_mobile','$users_message');";


   $result = mysqli_query($mysqli, $user_query);

    $user_id = mysqli_insert_id($mysqli);


    foreach($_POST['booktitle'] as $key => $bookTitle) {
        $bookTitle = mysqli_real_escape_string($mysqli, $bookTitle);
        $bookGenre = mysqli_real_escape_string($mysqli, $_POST['bookgenre'][$key]);
        $bookWriter = mysqli_real_escape_string($mysqli, $_POST['bookwriter'][$key]);
        $bookDescription = mysqli_real_escape_string($mysqli, $_POST['bookdescription'][$key]);

        $book_query = "INSERT INTO bookdetails(BookTitle ,BookGenre,BookWriter,
            BookDescription, UserId) VALUES('$bookTitle',
         '$bookGenre', '$bookWriter', '$bookDescription', '$user_id');";

        $result = mysqli_query($mysqli, $book_query);


   }

}

Someone suggested me to not use this method as it's insecure. Please suggest any secure option which would full-fill the requirement.

Thanks in advnace!

asked 13 secs ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 6 تير 1395 ساعت: 2:16

صفحه بندی