Thanks, I managed to fix my prob by moving the pilotnumber=XXXX to the last row. I was expecting that not to work when the program read the ini file, but it did. But if you can see a better way of doing things I'm more than happy to listen and give it a go.
I over came the ini file naming by creating a new folder and copying the orginal ini to that newly created folder. I then opened up the new ini file and made changes there in that folder.
All works great and all the user needs to do is enter their number once and press next. All folder creation and file copy/edit is done on the fly and takes only a few seconds before the user has all their files pop up on their screen.
I need to change the routine a little to surpress error messages if there is already a folder there, but that shouldn't be too hard. LOL Not that I've attempted that yet. But this is for first time creation of user files. I have used same code to simple recreate their ini file with the exeption of the folder creation and chmod. And that works fine.
This is my first time using php and I must say, although confusing at times for simple things, it's a great system to use. So excuse me in the future for any simple questions I might ask, but i'm a noob in php.
Here's the code I used. It's probably a mess and can be done better but I new to php and it does the trick. If you can see a better way of doing things, let me know.
<?php include('menu.htm'); ?>
<link rel="stylesheet" type="text/css" href="/css/css.css">
<table width="600" border="0" align="center">
<tr>
<td><p>
<?php
// Create Pilot ID variable
$newUser = $_POST[pNum];
// Make pilot Dir with pilot ID variable
mkdir('logs/AN'. $newUser , 0777);
// octal; correct value of mode
// Make sure the correct permissions are set
chmod('logs/AN'. $newUser .'/', 0777);
// Copy the current ini template to Pilot folder and rename to AN.ini
$from = 'test.ini';
$to = 'logs/AN' . $newUser . '/AN.ini';
copy($from, $to);
?>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
<p>Below are the results of your ini file creation: </p>
<p class="style1">If there is an error message above saying that there is already a folder created, please verify that you have entered your correct Ansett pilot number. If you have entered the correct number, please disregard the error message. </p>
<?php
// use ini from pilot folder and append PilotNumber & variable to end EOF
$filename = 'logs/AN'. $newUser .'/AN.ini';
$somecontent = 'PilotNumber=' . $newUser ;
$fileneeded = "<a href=http://ansett.scartdesign.com/fsacars";
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "<h1 class=FSACARS >Instructions. Please read carefully.</h1>";
echo "<ul>";
echo '<li><a href="http://www.satavirtual.org/fsacars/fsacars4.zip">Download and install the FSACARS program</a></li>';
echo '<li><a href="http://www.satavirtual.org/fsacars/fsacars4015.zip">Download and install the FSACARS Undate program</a></li>';
echo '<li><a href="/fsacars/downloads/AN.zip">Download Ansett setup files</a></li>';
echo '<li>Download your ini file - link below<br>(right click mouse and select <strong>"Save Target As"</strong> or <strong>"Save Link As")</strong></li>';
echo "<li>Place your ini file in your FSACARS directory as AN.ini</li>";
echo "</ul>";
echo "<br>";
echo "Please download your ini file for: $fileneeded/$filename> AN$newUser</a><br>";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
<p> </p>
<p>And that's it. You now have all the files required.</p>
<p class="header1">Installation:</p>
<ol>
<li>Install FSACARS and the FSACARS upgrade. </li>
<li>Extract the files from the AN.zip file and place in your FSACARS directory and overwrite existing files.</li>
<li>Place your AN.ini file in the FSACARS directory.</li>
<li>Start FS and select your airport at gate.</li>
<li>Start FSACARS</li>
<li><a href="http://www.ansett.aussim.com/forum/topic.asp?TOPIC_ID=632">Read post on how to use FSACARS</a>. It's not as hard as it may sound either.</li>
</ol>
<p>OK then, good luck and happy PIREPing from now on. If you require any assistance post it in the How-To forum and I will answer any question ASAP.</p>
<p> </p>
<p>Cheers<br>
Steph. AN128 </p>
<p> </p>
<p>Links to FSACARS:</p>
<p>FSACARS main site:<br>
<a href="http://www.satavirtual.org/fsacars/index.html">http://www.satavirtual.org/fsacars/index.html </a> </p>
<p>FSACARS files can be downloaded from here : <br>
<a href="http://www.satavirtual.org/fsacars/fsacars4.zip">http://www.satavirtual.org/fsacars/fsacars4.zip</a></p>
<p>FSACARS Update from : <a href="http://www.satavirtual.org/fsacars/fsacars4015.zip"><br>
http://www.satavirtual.org/fsacars/fsacars4015.zip</a></p>
<p>FSACARS forum can be found at : <a href="http://www.satavirtual.org/forum/"><br>
http://www.satavirtual.org/forum/</a></p></td>
</tr>
</table>
<p>
Cheers and thanks
Steph.