Jump to content

Overwriting variables in a file with php


Jax2

Recommended Posts

Hello guys, got a question that will hopefully be simple for someone to answer ....

 

I have a file named db.php that looks like this:

<?php
$db_host="";
$db_username="";
$db_dbname="";
$db_password="";
$db_prefix="";
?>

 

Now, what I am trying to do is to create an installation script for something I am working on. The very first part allows the user to configure their database (MySQL) ... (Yes, I am off to a shaky start already :( )

 

I have the variables stored in $_POST and they all display fine, but I am not sure how to write to the file.

 

I've read the manual on fopen, and I'm rather lost. I just want to have it add the variables where they go, so it looks more like this when it's done:

 

$db_host="localhost";
$db_username="MyName";
$db_dbname="DataBaseName";
$db_password="DBPassword";
$db_prefix="PF_";

 

Could anyone help me out here and perhaps point me to a good tutorial or something of that nature? Thank you!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.