Jump to content

how to change one variable thats in an array of 10 with a form


sycoj0ker

Recommended Posts

for example;

 

$example1 = "red";

$example2 = "blue";

$example3 = "green";

$example4 = "white";

$example5 = "black";

 

I have 5 options in a form, one dedicated to each example (1 to 5).. I want to go to the 3rd option (which is $example3) and change it from green to grey (all the colors are in a big list), without changing any other variables from what they are already set as at a different time.

 

help?

 

a friend gave me this to work off but I dont know how to integrate it:

 

fwrite($file, "$settings['example1']=\''.$_POST['Grey'].'\';'."\n");

Link to comment
Share on other sites

want to go to the 3rd option (which is $example3) and change it from green to grey
You will need to provide a better example of what you are wanting to do. "Change from green to grey", You may want to look into session variables and swap it with green, thus leaving the other session 'colors' in tact.

 

$_SESSION['color1'] = 'blue';
$_SESSION['color2'] = 'green';
$_SESSION['color1'] = 'red';

if (isset($_POST['option2'])) {
     $_SESSION['color2'] = 'grey'; //Or to your color table accordingly
}

 

Link to comment
Share on other sites

want to go to the 3rd option (which is $example3) and change it from green to grey
What is an example of what you are wanting to do? Can you not change the ratio (button) to a different color, and use the POST values accordingly?

 

without changing any other variables from what they are already set as at a different time.

So are you wanting to update JUST the one selected to grey, and not the others? ..

 

You're not making a whole lot of sense.. And I'd recommend using arrays, they are much more portable.

 

 

http://urbandead.org/halp/home.jpg - that's the homepage, note how they all have different colors?

http://urbandead.org/halp/admin.jpg - that's the admin panel, note how all the options are on ghost? ghost is the default option.

http://urbandead.org/halp/output.jpg - the form values from the admin is written to a file (http://urbandead.org/danger.php - if you look at the source code note the .css classes - they are the options)

 

I don't want to have to change all 100 options if only one box needs to be changed, I want all the form values to be saved how I set them, and not default to ghost each time because it takes 10 minutes to set them all again. I can post the source code if you need it.. that's what I mean by changing any variable that's in a big array using form options.

Link to comment
Share on other sites

if ($_POST['updatenotepad']) {
$updatenotepad = stripslashes(htmlspecialchars($_POST['updatenotepad'], ENT_QUOTES));
$shoutsettings ="<?php\n\$email = '$email';\n\$skinchoice = '$skinchoice';\n\$yourpassword = '$yourpassword';\n\$status = '$status';\n\$avatar = '$avatar';\n\$sig = '$sig';\n\$title = '$title';\n\$signup_ipa = '$signup_ipa';\n\$msn = '$msn';\n\$yim = '$yim';\n\$aim='$aim';\n\$icq = '$icq';\n\$www='$www';\n\$notepad = '$updatenotepad';\n\$birthday = '$birthday';\n\$postcount = '$postcount';\n?>";
$fp = fopen("./accounts/{$acfile}_user.php","w+");
fwrite($fp, $shoutsettings);
fclose($fp);
}

 

and

 

<?php
$email = 'none';
$skinchoice = 'Default';
$yourpassword = '';
$status = 'Guest';
$avatar = 'blank.gif';
$sig = '';
$title = '';
$signup_ipa = 'localhost';
$msn = '';
$yim = '';
$aim='';
$icq = '';
$www='';
$notepad = 'notepad';
$birthday = '';
$postcount = '0';
?>

 

they are examples, but would that work if I changed all the variables how it is now?

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.