315 posts
  • Bought between 100 and 499 items
  • Has been a member for 7-8 years
  • United States
timmylogue says

I’m trying to write something to an existing php file using FILE _APPEND.

I want to add the code below to “myString”, The full code. If I place that in between the quotes I get an error. It seems like it doesn’t like the $ symbol. What can I do? I’m not a php expert :)

$useradmin = array('login' => 'admin');    //// add this to myString

$file = "settings.php";
$myString = " ";

file_put_contents($file, $myString, FILE_APPEND);
$getData = file_get_contents($file);
echo $getData;

Thanks!
Timothy

315 posts
  • Bought between 100 and 499 items
  • Has been a member for 7-8 years
  • United States
timmylogue says

OK, disregard my last message. I’m now gonna use str_replace.

I got it working, but I need one last thing! I have a simple HTML form with a field name=”albumpass”

How do I add a .$_POST to the second str_replace so it submits what the user places inside that field.

Here is my code:
$fname = "settings.php";
$fhandle = fopen($fname,"r");
$content = fread($fhandle,filesize($fname));

$content = str_replace("defaultpass", "WHAT_EVER_USER_TYPED", $content);

$fhandle = fopen($fname,"w");
fwrite($fhandle,$content);
fclose($fhandle);

Thanks!

315 posts
  • Bought between 100 and 499 items
  • Has been a member for 7-8 years
  • United States
timmylogue says

Got it!

$_POST['albumpass'];
$fname = "settings.php";
$fhandle = fopen($fname,"r");
$content = fread($fhandle,filesize($fname));

$content = str_replace("defaultpass", "$albumpass", $content);

$fhandle = fopen($fname,"w");
fwrite($fhandle,$content);
fclose($fhandle);
639 posts
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
  • Has been a member for 1-2 years
  • Haiti
Crakken says

Looks like creating a thread about it helped you, you should post here more often :sarcasm:

315 posts
  • Bought between 100 and 499 items
  • Has been a member for 7-8 years
  • United States
timmylogue says

Looks like creating a thread about it helped you, you should post here more often :sarcasm:

haha you know what? This crap always happens to me.

I always search for my problems before posting on threads, then after post a thread I figure out my problem. I don’t get it :P

639 posts
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
  • Has been a member for 1-2 years
  • Haiti
Crakken says


Looks like creating a thread about it helped you, you should post here more often :sarcasm:

haha you know what? This crap always happens to me.

I always search for my problems before posting on threads, then after post a thread I figure out my problem, I don’t get it :P

Stuffs happen.

by
by
by
by
by
by