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
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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.