Jump to content


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


Form input storing as permanent variable

Recommended Posts

Is there a way to make a form input into a permanent variable, that can then be used on any other pages as long as the file they're stored in is included.

For example:

An installation file: the first page is where the user would input their MySQL Host, Username, Password and Database. Then I want the page to save this information to a config.php file, which can then be included on all the pages that need to correspond with the database using this information. Then on the second installation page, the tables would be inserted to the database, ect.

Just the only thing i'm not sure how to do is the permanent variable storing, how would I go about this?

Many thanks!! :)

Share this post

Link to post
Share on other sites
You'd want something like this:

<form action="form.php" method="post">
<p><input type="text" name="host" />
<p><input type="text" name="user" />
<p><input type="text" name="password" />
<p><input type="submit" value="hit it!" />

$host = $_POST['host'];
$user = $_POST['user'];
$password = $_POST['password'];

Share this post

Link to post
Share on other sites
Why not just use fopen, fputs to write to the external file? The above method already means you have them stored in variables..

Share this post

Link to post
Share on other sites


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.