Merge an action button commands to main page
<p>I have a page that called admin.php that has some cods and buttons. my problem is one of the buttons apply an action code that is originally HTML code but i converted it to php and the code is like this:</p>

<pre><code>echo "&lt;form action=\"write.php\" method=\"post\"&gt;\n"; 
echo " &lt;p&gt;your MoD name: &lt;input type=\"text\" name=\"mdname\" /&gt;&lt;/p&gt;\n"; 
echo " &lt;p&gt;&lt;input type=\"submit\" /&gt;&lt;/p&gt;\n"; 
echo "&lt;/form&gt;\n"; 
</code></pre>

<p>this code calls the write.php and write.php code is this:</p>

<pre><code>&lt;?php
header ('Location: admin.php ');
$myFile = "methods\actmod.txt";
unlink($myFile);
$handle = fopen("methods\actmod.txt", "a");
foreach($_POST as $variable =&gt; $value) {
   fwrite($handle, $variable);
   fwrite($handle, "=");
   fwrite($handle, $value);
   fwrite($handle, "\r\n");
}
fwrite($handle, "\r\n");
fclose($handle);
exit;
?&gt;
</code></pre>

<p>this code writes some data to txt file that called actmod.txt and returns to the admin page. i wanted to ask is there any way that i can merge write.php to the main admin.php page so when i hit the submit  button in the admin page it won use any external file and runs the commands directly from admin page and i wont have any external files behind the admin page?</p>

<p>i have seen lots of pages that has address like this "http://site.com/admin.php?act=write</p>

<p>i hope every body understand what i mean. i am new to php and i searched a lot and i appreciate to anybody's help. 
thank you  </p>
