0

Hello, I'm using a function for uploading images on the server and database. The only problem is that I can not properly put to the various alerts for required fields or missing and with happened insertion message.

For the moment my code, obviously wrong, is so:

include_once 'function/upload.php';

if(isset($_POST['submit'])) {

    if(empty($_POST['title'])){
        $error = "Manca il titolo";
    }

    if(empty($_POST['description'])){
        $error = "Manca la descrizione";
    }

    if(!empty($_FILES['image']['name'])) {
        //call thumbnail creation function and store thumbnail name
        $upload_img = imgUpload('image','uploads/','',TRUE,'uploads/thumbs/','260','260');
        //full path of the thumbnail image
        $thumb_src = 'uploads/thumbs/'.$upload_img;
        $success = "Caricato!";
    }
}

Which is the right syntax to write the errors in this case?

2
Contributors
1
Reply
8
Views
1 Year
Discussion Span
Last Post by TexWiller
0

your script is executed when server receives data via post at the moment you can't do anything on client side
you have 2 choices

`1. validate data before submit using jquery or js    see docs for .onsubmit event`
  1. if there any error you can redisplay the page showing the error message.
    hth.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.