Jump to content


Photo

Form input storing as permanent variable


  • Please log in to reply
3 replies to this topic

#1 joeholdcroft

joeholdcroft
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 May 2006 - 01:28 PM

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!! :)

#2 Allen4172

Allen4172
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 06 May 2006 - 01:47 PM

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!" />
</form>

<?php
$host = $_POST['host'];
$user = $_POST['user'];
$password = $_POST['password'];
?>


#3 joeholdcroft

joeholdcroft
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 May 2006 - 01:51 PM

Thanks. Yeah I know that much, but then how do i store those variables in another file permanently?

#4 Michael4172

Michael4172
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 07 May 2006 - 09:05 PM

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users