Link to home
Start Free TrialLog in
Avatar of Ananthahk
Ananthahk

asked on

HTML Button to Run PHP Script

Hello All,

I have three php script, 1.php, 2.php and 3.php.

I want to call these scripts using 3 HTML buttons, can any one help me with a simple HTML button code to call php script

Regards,
Anantha
ASKER CERTIFIED SOLUTION
Avatar of vrynxzent
vrynxzent
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Shinesh Premrajan
Shinesh Premrajan
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ananthahk
Ananthahk

ASKER

Hello Everybody

Thanks for your suggestion, I'm quite novice to any scripting so please excuse my questions

First solution (index.php) has some couding issue, I'm not able to run the script using php I get following error
 
# php index.php
PHP Parse error:  syntax error, unexpected T_STRING in /usr/local/apache2/htdocs/index.php on line 3

Second solution I just get 3 buttons but on clicking it does not execute the php script

Third sol : I get just three input text box on web page

This is the HTML script I'm using currently to call  1.php, 2.php & 3.php script.

Its works but runs the php  in new page thus remove the buttons, Can I display the output in same page ??

Or please advise if any changes required in the script.

HTML Code :
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="1.php">
<p>
<input type="submit" name="Submit" value="Current-stat">
</p>
</form>
</body>
</html

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="2.php">
<p>
<input type="submit" name="Submit" value="Maintenance-Env">
</p>
</form>
</body>
</html

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="3.php">
<p>
<input type="submit" name="Submit" value="Prodcution-Env">
</p>
</form>
</body>
</html

Php script is actually calling a load balancer to change the group priority

1.php

cat  1.php
<?php
$command1 = '/usr/bin/sudo /usr/bin/ssh root@192.168.0.1 b pool test1 list';
#$rt = shell_exec(escapeshellcmd($command));
$rt1 = shell_exec($command1);
echo $rt1;
?>


cat 2.php
<?php
$command1 = '/usr/bin/sudo /usr/bin/ssh root@192.168.0.1 bigpipe pool test1 { \
      lb method member ratio \
      min active members 1 \
      member 192.168.10.150:80 ratio 4 priority 2 \
      member 192.168.10.151:80 ratio 2 priority 2 \
      member 192.168.10.152:80 ratio 10 priority 10 }
';
$command2 = '/usr/bin/sudo /usr/bin/ssh root@192.168.0.1 b pool test1 list';

#$rt = shell_exec(escapeshellcmd($command));
$rt1 = shell_exec($command1);
$rt2 = shell_exec($command2);
echo $rt1;
echo $rt2;
?>

cat 3.php
<?php
$command1 = '/usr/bin/sudo /usr/bin/ssh root@192.168.0.1 bigpipe pool test1 { \
      lb method member ratio \
      min active members 2 \
      member 192.168.10.150:80 ratio 4 priority 2 \
      member 192.168.10.151:80 ratio 2 priority 2 \
      member 192.168.10.152:80 ratio 1 priority 1 }
';
#$rt = shell_exec(escapeshellcmd($command));
$command2 = '/usr/bin/sudo /usr/bin/ssh root@192.168.0.1 b pool test1 list';

#$rt = shell_exec(escapeshellcmd($command));
$rt1 = shell_exec($command1);
$rt2 = shell_exec($command2);
echo $rt1;
echo $rt2;
?>


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello Thansks for pointing fix on HTML code, My php script is actually logiing to device, executing a command and displaying the same.

I will try to clean up the script

Thanks all for your time

Regards,
Anantha