Jump to content

[HELP] File_exists() funtion


PokeTech

Recommended Posts

Well I'm trying to get this code working, but I'm having no luck what so ever... I'm trying to get it to display if the file is used (exists) or doesnt exist. Its a page with a form, then the username is the name of the page so $name.php, and then it creates it in a directory but I want to make it say File (username) exists please choose a different username.

 

Here's the code if you want to try and fix it:

 

<?
$center="<br><center>";
$ecenter="</center>";
$header="";
$bottom="";
if(isset($name, $gamename, $contact, $code1, $code2, $code3, $country, $card, $bio)) {
$fp = fopen("/home/www/poketech.net/site/wi-fi/users/$name.php","a");
$filename="../users/$name.php";
?>
<?
if (file_exists($filename)) {
    echo "<br><center>Username Already excists, Please choose a different one</center>";
} else {
    echo "<br><center>Your page is here: <a href=/site/wi-fi/users/$name.php>http://poketech.net/site/wi-fi/users/$name.php</a></center>";
}
?>
<? @ReadFile("url.php") ?>
<?
fputs($fp,($header).'<?PHPinclude("/home/www/poketech.freehostia.com/top.php");?>');
fputs($fp,nl2br($center).'<table border="1"><tr><td>Username:</td><td>');
fputs($fp,nl2br($name).'</td></tr><tr><td>Game Name:</td><td>');
fputs($fp,nl2br($gamename).'</td></tr><tr><td>Contact:</td><td>');
fputs($fp,nl2br($contact).'</td></tr><tr><td>Friend Code:</td><td>');
fputs($fp,nl2br($code1).'-');
fputs($fp,nl2br($code2).'-');
fputs($fp,nl2br($code3).'</td></tr><tr><td>Country:</td><td>');
fputs($fp,nl2br($country).'</td></tr><tr><td>Trainer Card:</td><td><img src="');
fputs($fp,nl2br($card).'"></td></tr><tr><td>Bio:</td><td>');
fputs($fp,nl2br($bio).'</td></tr></table>');
fputs($fp,nl2br($ecenter).'');
fputs($fp,($bottom).'<?PHP
include("/home/www/poketech.freehostia.com/bottom.php");?>');
fclose($fp);
} 
?>



<form action="<?="$PHP_SELF#results"?>" method="POST">
<table align="center" width="50%" border="0" class="style1" style="margin-bottom:100px;">
<tr>
  <td valign="top">Username:</td>
  <td><input name="name" type="text" size="30" maxlength="30" title="Username"/></td>
</tr>
<tr>
  <td valign="top">Game Name:</td>
  <td><input name="gamename" type="text" size="30" maxlength="30" title="Game Name"/></td>
</tr>
<tr>
  <td></td><td valign="top">
</tr>
<tr>
  <td valign="top">E-Mail:</td>
  <td><input name="contact" type="text" size="30" maxlength="35" title="E-Mail"/></td>
</tr>
<tr>
  <td valign="top">Friend Code:</td>
  <td>
  <input name="code1" type="text" size="4" maxlength="4"/> <input name="code2" type="text" size="4" maxlength="4" /> <input name="code3" type="text"   size="4" maxlength="4"/></td>
</tr>
<tr>
  <td valign="top">Country:</td>
  <td><input name="country" type="text" size="30" maxlength="100"/></td>
</tr>
<tr>
<tr>
  <td valign="top">Card:</td>
  <td><input name="card" type="text" size="30" maxlength="9999"/></td>
</tr>
<tr>
  <td valign="top">Bio:</td>
  <td><textarea cols=40 rows=5 name=bio wrap=virtual></textarea></td>
</tr>
<tr>
  <td colspan=2 align=center>
<input type=submit value=" Submit ">
<input type="reset" name="Reset" value="Reset" >
  <td>
</tr>
</table>
</form>

 

If anyone could help in fixing this that would be great, cause I've tried as many ways as I can think and now I'm stuck... So please help!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.