Just a warning that I am new to PHP (even more so Java), so I appreciate the help and the ability to be as hand-holding as possible. :bigyello:
My PHP page allows the user to upload their files for each state to our server where it is processed later. So, if the user uploaded a file for Texas last week, when they visit the page today the upload box next to Texas would say the Texas file was uploaded on 11/8/2012 and have a checkbox giving them the option to "Append" another file to the existing one uploaded on 11/8/2012.
If the user checks the "Append" checkbox the php does a fopen & fwrite to append the new file Texas file to the existing one.
Now, what I want to do is add a confirmation pop-up just in case the user "forgets" to check the "Append" checkbox so they don't accidentally overwrite the existing file. I read using javascrit's confirm() function is the easiest way, but I can't get it to work. Here is the PHP code I have so far.
I found some javascript for this (see below). I know php is server side while java is client side, but I can't get it to work "with" the php code even though it appears to be possible from what people are saying when I research "how to". The "confirm" part of the PHP code above is where I was the True/False values from the java confirm to be populated.
<script type="text/javascript">
<!--
var answer = confirm ("Are you sure you want to overwrite the existing file?")
return answer
// -->
</script>
My PHP page allows the user to upload their files for each state to our server where it is processed later. So, if the user uploaded a file for Texas last week, when they visit the page today the upload box next to Texas would say the Texas file was uploaded on 11/8/2012 and have a checkbox giving them the option to "Append" another file to the existing one uploaded on 11/8/2012.
If the user checks the "Append" checkbox the php does a fopen & fwrite to append the new file Texas file to the existing one.
Now, what I want to do is add a confirmation pop-up just in case the user "forgets" to check the "Append" checkbox so they don't accidentally overwrite the existing file. I read using javascrit's confirm() function is the easiest way, but I can't get it to work. Here is the PHP code I have so far.
PHP Code:
<?
bunch of php code....
if($file_exits)
{
//verifieds if the Append checkbox was checked
if(isset($_POST['Append']))
{
php code appends new file to existing file
}
else
{
//verifies the user wants to overwrite the existing file if the append checkbox is not checked
if (confirm("Are you use you want to overwrite the existing file?"))
{
php code to overwrite the existing file with the new file
}
else
{
exit();
}
}
}
else
{
php code to copy the file since it doesnt exist
}
more php code
?>
<script type="text/javascript">
<!--
var answer = confirm ("Are you sure you want to overwrite the existing file?")
return answer
// -->
</script>