acoole Posted March 9, 2008 Share Posted March 9, 2008 Hey there, I want to make my script check if the file exsists and if it does, come up with a message saying "Account Exsists". Here's the script: <?php $path = "/home/sfrp/sa-mp/scriptfiles/"; // this will prevent XSS echo "<h1>Congratulations!</h1> - You're registered on "; // replace $_SESSION['username'] will the variable that holds your user name $file = fopen($path.$_POST["name"].".ini","a+"); $text = "Key=" . $_POST["age"]; $text .= "Level=1 AdminLevel=0 DonateRank=0 UpgradePoints=0 ConnectedTime=0 Registered=1 Sex=1 Age=25 Origin=2 CK=0 Muted=0 Respect=0 Money=25900 Bank=50000 Crimes=0 Kills=0 Deaths=1 Arrested=0 WantedDeaths=0 Phonebook=0 LottoNr=0 Fishes=0 BiggestFish=0 Job=0 Paycheck=1175 HeadValue=0 Jailed=0 JailTime=0 Materials=0 Drugs=0 Leader=0 Member=0 FMember=255 Rank=0 Char=0 ContractTime=0 DetSkill=0 SexSkill=0 BoxSkill=0 LawSkill=0 MechSkill=0 JackSkill=0 CarSkill=0 NewsSkill=0 DrugsSkill=0 CookSkill=0 FishSkill=0 pSHealth=0.0 pHealth=48.0 Int=0 Local=255 Team=3 Model=264 PhoneNr=8284 House=255 Bizz=255 Pos_x=246.6 Pos_y=-1161.9 Pos_z=1029.6 CarLic=0 FlyLic=0 BoatLic=0 FishLic=0 GunLic=0 Gun1=0 Gun2=0 Gun3=0 Gun4=0 Ammo1=0 Ammo2=0 Ammo3=0 Ammo4=0 CarTime=0 PayDay=4 PayDayHad=0 CDPlayer=0 Wins=0 Loses=0 AlcoholPerk=0 DrugPerk=0 MiserPerk=0 PainPerk=0 TraderPerk=0 Tutorial=1 Mission=0 Warnings=0 Adjustable=1 Fuel=0 Married=0 MarriedTo=No-one "; // write contents fwrite($file,$text); // close the file fclose($file); ?> Link to comment https://forums.phpfreaks.com/topic/95219-simple-help/ Share on other sites More sharing options...
kenrbnsn Posted March 9, 2008 Share Posted March 9, 2008 Look at the function file_exists() Ken Link to comment https://forums.phpfreaks.com/topic/95219-simple-help/#findComment-487719 Share on other sites More sharing options...
acoole Posted March 9, 2008 Author Share Posted March 9, 2008 Hi, Thanks, I've tried that out but I keep mucking it up, can you please give me an example of that implemented into my script? Thanks! Link to comment https://forums.phpfreaks.com/topic/95219-simple-help/#findComment-487722 Share on other sites More sharing options...
kenrbnsn Posted March 9, 2008 Share Posted March 9, 2008 Try: <?php if (file_exists($path.$_POST["name"].".ini")) echo 'Account exists<br>'; else { $file = fopen($path.$_POST["name"].".ini","a+"); $text = "Key=" . $_POST["age"]; $text .= "Level=1 AdminLevel=0 DonateRank=0 UpgradePoints=0 ConnectedTime=0 Registered=1 Sex=1 Age=25 Origin=2 CK=0 Muted=0 Respect=0 Money=25900 Bank=50000 Crimes=0 Kills=0 Deaths=1 Arrested=0 WantedDeaths=0 Phonebook=0 LottoNr=0 Fishes=0 BiggestFish=0 Job=0 Paycheck=1175 HeadValue=0 Jailed=0 JailTime=0 Materials=0 Drugs=0 Leader=0 Member=0 FMember=255 Rank=0 Char=0 ContractTime=0 DetSkill=0 SexSkill=0 BoxSkill=0 LawSkill=0 MechSkill=0 JackSkill=0 CarSkill=0 NewsSkill=0 DrugsSkill=0 CookSkill=0 FishSkill=0 pSHealth=0.0 pHealth=48.0 Int=0 Local=255 Team=3 Model=264 PhoneNr=8284 House=255 Bizz=255 Pos_x=246.6 Pos_y=-1161.9 Pos_z=1029.6 CarLic=0 FlyLic=0 BoatLic=0 FishLic=0 GunLic=0 Gun1=0 Gun2=0 Gun3=0 Gun4=0 Ammo1=0 Ammo2=0 Ammo3=0 Ammo4=0 CarTime=0 PayDay=4 PayDayHad=0 CDPlayer=0 Wins=0 Loses=0 AlcoholPerk=0 DrugPerk=0 MiserPerk=0 PainPerk=0 TraderPerk=0 Tutorial=1 Mission=0 Warnings=0 Adjustable=1 Fuel=0 Married=0 MarriedTo=No-one "; // write contents fwrite($file,$text); // close the file fclose($file); } ?> Ken Link to comment https://forums.phpfreaks.com/topic/95219-simple-help/#findComment-487728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.