Re: Question

From: Date: Fri, 17 Dec 2004 15:39:57 +0000
Subject: Re: Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-204579@lists.php.net to get a copy of this message
I assume by edit you mean change the value to something completely new. If you are having the user input the new value you 1) must make sure it is valid input and 2)move it into the array value (maybe set the array as a session variable so it crosses over to the next page instead of being re initialized). Maybe something like: if(isset($_POST['submit']){
    // make sure the input is valid first
    $_SESSION['config']['email'] = $_POST['email'];
    $_SESSION['config']['meta_author'] = $_POST['author'];
} if (!isset($_SESSION['config'])){
    $_SESSION['config']= array(
        'email' => 'E-mail',
        'meta_author' => 'Author')
} <input type = "hidden" name="email" type="text"
    value="<?php print $config[email];?>">
<input type = "hidden" name="author" type="text"
    value="<?php print $config[meta_author]; ?>">
Respectfully, Ligaya Turmelle --- Life is a game... so have fun. --- www.PHPCommunity.org Open Source, Open Community Visit for more information or to join the movement Tom Luigjes wrote:
Hi, I'm trying to make a little script to edit arrays. For example, i have an array file named config.php, and it holds this: <?php $config = array(
      'email' => 'E-mail',
      'meta_author' => 'Author',
?> I wish to edit this file, through another file, named edit.php, or admin.php, i would like to use forms for it. At the moment i've found out how to show the arrays within a text field, but now i wish to edit them through the same text field. With buttons etc. Here's how i call the arrays from the file: <input name="hiddenfield" type="text" value="<?php print $config[email]; ?>"> <input name="hiddenfield" type="text" value="<?php print $config[meta_author]; ?>"> Is there anything that can let me edit it? I think i will have to edit it through a form, it might be simple, though it might not be, please help me out!


« previous php.general (#204579) next »