Hi there,
I worked it out in the end and it is already up and running.
It is about kites, trees was just an example. My friend wanted to have a sale on his webpage hence me wanting to find a way to do it right.
This is what I came up with in the end, and I will have a go at your answers as it will happen once again that is for sure.
What I am doing is sending the script to a certain folder called "sold", both images are called the same but are variant in both folders.
<?php
$kite_one_Img = "";
$kite_one_Img_Active = "../img/Sale2017/";
$kite_one_Img_Sold = "../img/Sale2017/sold/";
$folder = "ActiveOrSold/";
$Img = $folder ."kite_one.inc";
$fn = $folder ."kite_one.txt";
if (isset($_POST['kite_one']))
{ $kite_one = $_POST['kite_one'];
$fp = fopen($fn,"w") or die ("Error opening file in write mode!");
fputs($fp,$kite_one);
fclose($fp) or die ("Error closing file!");
}
if (isset($_POST['kite_one'])){
$kite_one_file= fopen($Img,"w") or die ("Error opening file in write mode!");
fwrite($kite_one_file, "<?php");
fwrite($kite_one_file, "\n");
fwrite($kite_one_file, "$" ."kite_one_Img" ." = ");
fwrite($kite_one_file, "$" ."kite_one_Img_" .$kite_one);
fwrite($kite_one_file, " ;" ."\n" ."?>");
fclose($kite_one_file);
}
include ($folder ."kite_one.inc");
?>
<tr class="item">
<td align="left"><strong>Kite_one</strong></td>
<td width="60"><img src="<?=$kite_one_Img;?>kite_one.jpg" style="width:60px; height:60px; border:none;"></td>
<td align="center"><form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post"><input type="text" name="kite_one" size="3" id="kite_one" maxlength="8" value="<?php readfile($fn); ?>" > <input type="submit" value="change">
</form>
</td>
</tr>
So basicaly it writes to a file the variable
$kite_one_Active
or
$kite_one_Sold
whatever the client types into the form.
Then at the html side of things I just call for the .inc file and print the variable $kite_one_Img
The .inc file looks like this after the client types Active.
<?php
$kite_one_Img = $kite_one_Img_Active ;
?>
The other file it writes to, writes just the word "Sold" or "Active" so the client does not have to read PHP code .
There were over 30 items on sale so I had to do this for every item, maybe one of your answers is a much friendlier way?
I will work with them for sure.
Thanks a lot for your help.