Post variables to database

Hey there,

I am writing a Plugin for WP, and all I want to do is save some variables to the database so that I can use them within my theme.

I don’t want to use a pre-written plugin for this. I’m doing this for educational reasons.

So I’ve added a settings page to my WP admin. Now inside this I want to have a form with two fields that the user can save variables to, namely address, and telephone number.

I know that I can use this php method to store the variables:


< ?php
$variable = $_POST['Opt01'];
update_option(‘myPlugin_Opt01&#8242;, $variable);
?>

so that I can use it later like this:


< ?php
$variable = get_option(‘myPlugin_Opt01&#8242;);
?>

but I want to put this into a form…


<form>
Address: <input type="text" name="address" /><br/>
Telephone Number: <input type="text" name="tel_num" /><br/>
<input type="submit" value="Save">
</form>

…something like that, but obviously I need to add the php method to the form so that it will store the data in the database.

Any help would be great.

Cheers,
Mike

:slight_smile: