FreeHostia Forums
http://forum.freehostia.com/

Need some PHP help!!
http://forum.freehostia.com/viewtopic.php?f=7&t=8800
Page 1 of 1

Author:  PokeTech.net [ Wed Jan 30, 2008 4:10 pm ]
Post subject:  Need some PHP help!!

I'm not sure if this forum is the right one but if not just move it (mods) please.

I'm trying to make a interactive/register page to my site.

The form allows people to create there own page on the site, the username acts as the url ($name.php) but I'm trying to get it so that if the file already exists a message will appear saying that the name can no longer be used (or in this case, file because there creating files.) I'm have like no luck finding a code I've googled it about a million times (something like that) but is anyone here an expert that can help me?

I tried this one:

Code:
<?php
$filename = '/site/wi-fi/users/$name.php';

if (file_exists($filename)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}
?>


Its not really working though... Can anyone help?

Author:  Josh.Waller [ Wed Jan 30, 2008 6:10 pm ]
Post subject: 

try this for the file name


temp.php
[code]
<?php
echo getcwd();
?>
[code]

from there you can work out what directory you are in, by using ../../../ you can move back say 3 directorys. ../ (1) ../../ (2) ../../ (3) and so on. Using this method you can get back to your users folder (if your ahead of it) and you will get the correct start.

If you dont understand what i am saying just say and i will try explain it a bit better.


[MySQL, PHP & CGI/Perl]

Author:  Hinty [ Tue Feb 05, 2008 2:55 am ]
Post subject: 

change $filename to

$filename = '/wi-fi/users/$name.php';

shot in the dark

Author:  Ikkerens [ Thu May 22, 2008 1:18 pm ]
Post subject:  Try this...

I'd first, clean up your php code a bit:

Code:
<?php
$filename = './site/wi-fi/users/'.$name.'.php';


If ( file_exists($filename) )
{
   echo 'The file '.$filename.' exists!';
}
Else
{
   echo 'The file '.$filename.' doesn\'t exist!';
}

?>

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/