Reputation: 41
I need to rename any file or folder on my Web-based system in dynamic way by getting the Oldname from $_REQUEST["item"] & the Newname from prompt box, my javascript code is :
<script type="text/javascript">
var name;
function rename(){
var name= prompt("Please enter a new name for the item:", "");
if (name=="")
rename();
}
<?php $name ?>= name;
</script>
<a onclick="rename()" href="index.php?action=rename&newname=<?php echo $name; ?>&item=<?php echo $value["path"]; ?>" >Rename</a>
where is the $value["path"] is the link for each item in the page
Php function :
private function rename() {
rename($_REQUEST["item"], $_REQUEST["newname"]);
}
my .htaccess file :
RewriteEngine On
RewriteRule ^(.*)/index.php$ index.php?controller=$1&%{QUERY_STRING} [L]
there is a lot of code to open file & to call my function the problem is that $_REQUEST["newname"] is Undefined variable & the prompt box doesn't appear??
Note:there is no problem with calling the function ^_^
Upvotes: 1
Views: 1342
Reputation: 324760
And another one for the count...
PHP is run on the server, JavaScript is run in the browser.
PHP can generate JavaScript in the same way it can generate HTML, but in order for JavaScript to communicate back to PHP you need to use AJAX.
Upvotes: 1