load other template
Moderator: General Moderators
load other template
So i have 2scripts(to start and stop a server) and 2 templates( 1 with a start button and another with a stop button). I want a do a script that shows the start template when the server is off. Than when a user clicks the start button it executes the script and when the page reloads it loads the template with the stop button. Than if a users decides to click a stop button, the page reloads, execute a script and load the start template.
Any hints on how i can do it?
Any hints on how i can do it?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: load other template
It may be simpler to have one script that submits to itself. Have PHP generate either a Start button that submits a stop parameter or a Stop button that submits a start parameter. Then the script can stop or start based on the parameter.
(#10850)
Re: load other template
any hints how i can do it?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: load other template
Code: Select all
<form method="post" enctype="multipart/form-data">
<input type="submit" name="start" value="Start" />
</form>
<?php
include('ssh_con.php');
$stop = 'screen -S test -X quit';
ssh2_exec($con, $stop);
?>Code: Select all
<form method="post" enctype="multipart/form-data">
<input type="submit" name="stop" value="Stop" />
</form>
<?php
include('ssh_con.php');
$start = 'screen -d -m -S test /home/servers/ts/test/ts3_server';
ssh2_exec($con, $start);
?>Till now i only made this code.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: load other template
There are many ways to do this, but the simplest would be to add action="" to each form:
stop.php
start.php
stop.php
Code: Select all
<form action="start.php" method="post" enctype="multipart/form-data">
<input type="submit" name="start" value="Start" />
// the rest of the stop scriptCode: Select all
<form action="stop.php" method="post" enctype="multipart/form-data">
<input type="submit" name="stop" value="Stop" />
// the rest of the start script(#10850)
Re: load other template
sry to posting late but i was a little bit busy with coding.
Thanks for your help till now it's working fine
Thanks for your help till now it's working fine
Re: load other template
Now i have a problem. When example i press the start button and loads the stop.php it executes some coding. When refreshing it it executes the coding again. Is there anything i can do so if a user refreshes the code will not be executed again.
Problem solved too using mysql variable.
Problem solved too using mysql variable.