Caling a Function from a php generated <A HREF>
Moderator: General Moderators
- moiseszaragoza
- Forum Commoner
- Posts: 87
- Joined: Sun Oct 03, 2004 4:04 pm
- Location: Ft lauderdale
- Contact:
Caling a Function from a php generated <A HREF>
Calling a Function from a php generated <A HREF>
I have been trying to attach a function to a php generated <a href> but I cant figured it out.
I have been trying to attach a function to a php generated <a href> but I cant figured it out.
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
- moiseszaragoza
- Forum Commoner
- Posts: 87
- Joined: Sun Oct 03, 2004 4:04 pm
- Location: Ft lauderdale
- Contact:
here is my code
Code: Select all
<?php
$dir = "../../../myDirectory/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "<a href='#'>Delete File </a> <a href='$dir$file' target='_self'>filename: $file : </a>" . "<br>";
}
closedir($dh);
}
}feyd |
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
you cannot directly attach any php functions to a html link, they are on seperate sides of requests: php is server-side (at this time), and html is client-side.
The code you posted isn't trying to attach a function or any php code to a link. If anything, it'd just attempt to give a link to a file/directory in $dir.
The code you posted isn't trying to attach a function or any php code to a link. If anything, it'd just attempt to give a link to a file/directory in $dir.
- moiseszaragoza
- Forum Commoner
- Posts: 87
- Joined: Sun Oct 03, 2004 4:04 pm
- Location: Ft lauderdale
- Contact:
So my real problem is
Code: Select all
<?php
$dir = "../../../myDir/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "<a href='WHAT GOES HERE TO CALL MY FUNCTION'>Delete File </a> <a href='$dir$file' target='_self'>filename: $file : </a>" . "<br>";
}
closedir($dh);
}
}Code: Select all
<?php
function DeletemyFile($dir,$file)
{
unlink($dir$file)
echo "the file : $file has been deleted from: $dir ";
}
?>- moiseszaragoza
- Forum Commoner
- Posts: 87
- Joined: Sun Oct 03, 2004 4:04 pm
- Location: Ft lauderdale
- Contact:
How would I pass data from point A to point B
How would I pass data from point A to point B
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
pass some form of identification via the url:
http://www.yoursite.com/deletescript.php?file=foo.gif
$_GET['file'] = 'foo.gif';
this is basic scripting 101 stuff..
http://www.yoursite.com/deletescript.php?file=foo.gif
$_GET['file'] = 'foo.gif';
this is basic scripting 101 stuff..
- moiseszaragoza
- Forum Commoner
- Posts: 87
- Joined: Sun Oct 03, 2004 4:04 pm
- Location: Ft lauderdale
- Contact:
- moiseszaragoza
- Forum Commoner
- Posts: 87
- Joined: Sun Oct 03, 2004 4:04 pm
- Location: Ft lauderdale
- Contact:
My Script on de Show Files
So my script on the delete page should look like :
But wen I run it I get an error
Parse error: parse error, unexpected T_FUNCTION in Directory/Deletefile.php on line 4
and line 4 has
1 <?php
2 $file = $_GET['file']
3
4 function DeletemyFile($file)
5 {
6 //unlink($dir$file)
7 echo "the file : $file has been delete ";
8 }
9 ?>
Code: Select all
<?php
$dir = "../../../mydir/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "<a href='Deletefile.php?file=$file'>Delete File </a> <a href='$dir$file' target='_self'>filename: $file : </a>" . "<br>";
}
closedir($dh);
}
}
?>So my script on the delete page should look like :
Code: Select all
<?php
$file = $_GETї'file']
function DeletemyFile($file)
{
//unlink($dir$file)
echo "the file : $file has been delete ";
}
?>Parse error: parse error, unexpected T_FUNCTION in Directory/Deletefile.php on line 4
and line 4 has
1 <?php
2 $file = $_GET['file']
3
4 function DeletemyFile($file)
5 {
6 //unlink($dir$file)
7 echo "the file : $file has been delete ";
8 }
9 ?>
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: