It is currently Tue Mar 19, 2024 10:50 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Need some PHP help!!
PostPosted: Wed Jan 30, 2008 4:10 pm 
Newbie
Newbie

Joined: Wed Jan 30, 2008 4:02 pm
Posts: 13
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?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 30, 2008 6:10 pm 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
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]

_________________
http://www.mjmclocks.co.uk


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 05, 2008 2:55 am 
Newbie
Newbie

Joined: Sat Aug 11, 2007 5:30 pm
Posts: 20
change $filename to

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

shot in the dark

_________________
Ethical Hacker
http://encription.co.uk


Top
 Profile  
 
 Post subject: Try this...
PostPosted: Thu May 22, 2008 1:18 pm 
Newbie
Newbie

Joined: Sat Mar 29, 2008 3:37 pm
Posts: 8
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!';
}

?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ]  Moderators: Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Hosting | Domains | Servers | Extras | Order | Support | Contacts | FreeHostia © 2011