I have recently been learning PHP, in doing so one of my friend who already knows PHP told me that the best way to learn, is to work on a project. So I went on a mission to make a basic control panel. This control panel has the basic features, the ability to view server files, stop start and restart the server.
NECESSARY:
Alright, here is the important information. I am using Windows 7 with WAMP, (Apache, phpMyAdmin etc.)
The contents of the PHP starting script:
<?php
if(isset($_POST['submit']))
{
echo exec('start_srv.bat');
echo "Server started, this may take a few seconds.";
} else {
?>
<form action="" method="post">
<input type="submit" name="submit" value="Start">
</form>
<?php
}
?>
The contents of the batch file (start_srv.bat):
(example purposes only)
START NOTEPAD.EXE
Now, when I click the 'Start' button the page just loads and does not execute the batch file which would usually run notepad (or when it gets serious, the server cmd file).
Without further adieu, my second problem.
The index/main code file.
<form action="saves/rsave.php" method="post">
<textarea name="save" rows="25" cols="75">
<?php
include("c:/Users/Jack/Desktop/ventrilo/ventrilo_srv.rank");
?>
</textarea><br/>
<INPUT TYPE="SUBMIT" VALUE="Save">
</form>
file 'saves/ranksave.php'
<?php
$f = fopen('c:/Users/Jack/Desktop/ventrilo/vetnrilo_srv.rank', 'w');
fwrite($f, $_POST['save']);
fclose($f);
header('Location: ../saved/ranksave.php');
?>
I am unsure if it not saving due to my PHP code error, or due to the fact that PHP can view(include) other files (.rank) but cannot edit them.
Hope someone can assist,
Jack.


Sign In
Create Account

Back to top









