Execute scipt via Html button using php

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Locked
yash1947
Registered User
Posts: 2
Joined: Wed Jun 13, 2018 2:54 pm

Execute scipt via Html button using php

Post by yash1947 » Wed Jun 13, 2018 3:10 pm

Hi all,
I am trying to execute a shell script via php and I want to do that using a button i.e. html button. If you click that button, then it should execute that script. In short I need to refresh the page contents by hitting a button present on that page.

I have written the code, but that is not working. As soon as I load the php page (abc.php), it starts executing the script in loop and never stops.

Below is the code :
<?php
if(['button1']) {fun1();}
function fun1() { shell_exec("sh /home/test.sh");
header('Location: http://1.2.3.4/abc.php?success=true');
}
?>

<html>
<body>
<center><button id=btnfun1 name=btnfun1 onClick='location.href=?button1=1'>Refresh</button> <a href=http://1.2.3.4/abc1.html >
<button>HOME</button></a> <a href=http://1.2.3.4/abc2.html >
<button>BACK</button></a>
</body>
</html>
<code type="php"></code>

User avatar
Mick
Support Team Member
Support Team Member
Posts: 19986
Joined: Fri Aug 29, 2008 9:49 am
Location: Cardiff

Re: Execute scipt via Html button using php

Post by Mick » Wed Jun 13, 2018 3:56 pm

This board is for support of the phpBB bulletin board software not general PHP support. PHP Support may be better for you.
"The more connected we get the more alone we become" - Kyle Broflovski

There are no ‘threads’ in phpBB, they are topics.

yash1947
Registered User
Posts: 2
Joined: Wed Jun 13, 2018 2:54 pm

Re: Execute scipt via Html button using php

Post by yash1947 » Tue Jun 19, 2018 6:02 am

I feel that there is some issue in logic ?

Locked

Return to “[3.2.x] Support Forum”

Who is online

Users browsing this forum: invenio, Paul, Restless Rancor, sakm and 14 guests