I'm just beggining with PHP and I want to create a php code.
The purpose of my page is to ask the user to enter a period and to select a file to upload (into the database).
if the period exists on the database, we ask the user if he want to erase these lines and upload the new file. (confirm / cancel). else, we upload the file normaly.
Now, i did the insert part:
$handle = fopen($_FILES['filename']['tmp_name'], "r");
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
// code to insert here
}
but i don't know how to ask the user, then how to continue the treatment.
It would be simple if the user gets a confirm box and then get the value of the clicked button... (I know how to do this on desktop application, not on web apps).
Do you have any idea ?
Thanks in advance.
This is not the job og PHP, as PHP is only compiled on the server into a html file. What you really need is any asynchronous functionallity lika AJAX
to perform a check of the period in the background.
PHP is a server side language, which means that all the PHP code is calculated, and when it's done it sends the output to the browser. If you want user interaction you can do it with client side languages like javascript
What you want is a javascript confirm dialog like this. This needs to be done client side, since you can't stop a server side script midway. If the user confirm it will trigger you php script
confirm("Press a button!");