• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

PHP + MySql help

Gman243

New Member
I'm trying to make a database editing page but i don't know how to do something. It's a form, where the enter the hostname, database name, and password. What I want to do is have the what they entered stored in a variable whereas the host they enter is $host and the db they enter is $db and so on. How would I go about that?
 
Your inputs would automaticaly be parsed as variables from a form, e.g if you had an input like <input name="user" type="text">

once you submit the form, you already have a variable $user
 
form.html:
Code:
<form action="blah.php" method="post">
Host:<br />
<input type="text" name="host" value="" /><br /><br />
DB:<br />
<input type="text" name="db" value="" /><br /><br />
<input type="submit" name="submit" value="Submit" /><br />
</form>

blah.php:
PHP:
<?php

$host = $_POST['host'];
$db = $_POST['db'];

// do what you want after setting variables...

?>
 
if register_globals option of PHP is on,then you can use simply the input name as variable name to access data,otherwise you need $_POST['yourvar'] form

since $_POST was introduced in PHP version 4.1.0 for earlier versions you should use
$HTTP_POST_VARS
 
Back
Top