file - PHP fopen not working -


i can't figure out, keep getting unable create group.

what i'm attempting submit forum, , creates file info in it. if group name exist(the file) tell them that. though keep getting stated "unable create group" die message.

this php part:

<?php if($_post['ownername'] && $_post['groupname']){  $ownername = htmlspecialchars($_post["ownername"]); $groupname = htmlspecialchars($_post["groupname"]);  echo 'owner ' . $ownername . ' , group ' . $groupname; $groupfile = '/groups/' . $groupname . '.txt';  if(file_exists($groupfile) == false){     $newgroup = fopen($groupfile, 'w') or die("unable create group");     $txt = "users:" . $ownername;     fwrite($newgroup, $txt);     fclose($myfile);     echo "<font style='color:green'>the group has been created! may access <a href='chat.php?group=" . $groupname . "'>here</a></font>"; } else {     echo "<font style='color:red'>the group name taken, please use name or wait released</font>"; } } ?> 

then html part:

<form action=<?php echo htmlspecialchars($_server["php_self"]); ?> method="post"> <input type="text" name="ownername" placeholder="username"/> <input type="text" name="groupname" placeholder="group name"/> <input type="submit" value="create"/> </form> 

any , appreciated, thank much!

if filename doesn't exist yet, use 'x' instead of 'w' create file , allow writing into.

$newgroup = fopen($groupfile, 'x'); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -