Jump to content

[SOLVED] $_POST problems


newbtophp

Recommended Posts

Im using $_POST to submit to variables in my config file, but the problem is everytime I view the form, the fields are blank so it looks like the variables are empty.

 

Is their a way I can make the field default values be whatever is currently in the variables?. So for example if I edit the form and I add phpfreaks.com to the siteurl field, everytime I visit that form the default value of that field would be that? (unless changed).

 

My code:

<?php
include("config.inc.php");
echo "<form action='form.php' method='post' name='Form'>";
?>Website Url: (this edits $siteurl)<BR>

<input type="text" name="siteurl" size="25"><BR><BR> 

Website Title: (this edits $site_title)<BR>

<input type="text" name="site_title" size="25"><BR><BR>

Your Email: (this edits $email)<BR>

<input type="text" name="email" size="25"><BR><BR>

<input name="submit" type="submit" value="Submit">
</form>
<?php
if(!empty($_POST["submit"]))
{
$out='<?php
//Website Url
$siteurl="'. (isset($_POST["siteurl"])? $_POST["siteurl"]:'') .'";
//Website Title
$site_title="'. (isset($_POST["site_title"])? $_POST["site_title"]:'') .'";
//Your Email
$email="'. (isset($_POST["email"])? $_POST["email"]:'') .'";
?>';
file_put_contents("config.inc.php",$out);
}

?> 

 

Thanks for your help

Link to comment
https://forums.phpfreaks.com/topic/169545-solved-_post-problems/
Share on other sites

It seems you want the form to retrieve data from config.inc.php and display it on the forms to edit?

 

<input type="text" name="site_title" size="25" value="<?=$title;?>">

 

$title will be whatever was the variable in config.inc.php.. So it'd show..

 

Form: [My site!], instead of blank.

 

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.