I want to write data into an already exsiting code: Delete: <form method="post" action="this file's name"> <select name='delete'> I want to write the data here </select> <input type="submit" value="submit"> I want to write the data in the "select" form (the bold section), not in the beggining of the file, how can i do it ? thanks in advance
You're going to need some sort of template functionality. In your form (say deleteform.html) have: <form method="post" action="this file's name"> <select name='delete'> ##DATA## </select> <input type="submit" value="submit"> Code (markup): Notice the ##DATA## part--this is a 'variable' where you want your data to go. Basically you need to get the file contents into a string (try file_get_contents()), then run a find and replace (like str_replace()) finding '##DATA##' and replacing with your data. Then in your new variable you'll now have the data you need. Now you just need to overwrite the current contents of deleteform.html with the new HTML created, and that should be it! There are other ways to do this, but this should at least give you a starting point of what you need to do.
You can overwrite <?php if (isset($_POST["Submit"])) { $string = '<?php $dbhost = "'. $_POST["dbhost"]. '"; $dbuname = "'. $_POST["dbuname"]. '"; $dbpass = "'. $_POST["dbpass"]. '"; $dbname = "'. $_POST["dbname"]. '"; $prefix = "'. $_POST["prefix"]. '"; $user_prefix = "'. $_POST["user_prefix"]. '"; $dbtype = "'. $_POST["dbtype"]. '"; ?>'; $fp = fopen("config.php", "w"); fwrite($fp, $string); fclose($fp); } include "config.php"; ?> <form action="submit.php" method="post" name="install" id="install"> <p><?=$dbhost?> <input name="dbhost" type="text" id="dbhost" value="<?=$dbhost?>"> DB Host</p> <p><?=$dbuname?> <input name="dbuname" type="text" id="dbuname" value="<?=$dbuname?>"> DB Username</p> <p><?=$dbpass?> <input name="dbpass" type="password" id="dbpass" value="<?=$dbpass?>"> DB Pass </p> <p><?=$dbname?> <input name="dbname" type="text" id="dbname" value="<?=$dbname?>"> DB Name </p> <p><?=$prefix?> <input name="prefix" type="text" id="prefix" value="<?=$prefix?>"> DB Prefix</p> <p><?=$user_prefix?> <input name="user_prefix" type="text" id="user_prefix" value="<?=$user_prefix?>"> Userprefix</p> <p><?=$dbtype?> <input name="dbtype" type="text" id="dbtype" value="<?=$dbtype?>"> DB Type </p> <p><input type="submit" name="Submit" value="Install"></p> </form> PHP:
it not work in IE, replace : <p><input type="submit" name="Submit" value="Install"></p> by : <input type="hidden" name="Submit" value="122345"> <input type="submit" value="Install">