Page 1 of 1
"command line"-type PHP interface?
Posted: Wed Jan 05, 2011 1:44 pm
by TalonP
Hello PHP experts!
I want to begin by referencing this website:
http://www.goosh.org/
I believe that this site in particular is using mostly JS to get this done. I was wondering if I would be able to create an identical interface using HTML/PHP alone. I'm not asking for anyone to write my code, I'm more or less just wondering if anyone here has done this before, or if anyone can point me in the right direction. I'm looking for any kind of documentation on it.
I'm relatively new to PHP, but I'll pick it up fast. I'm a C/C++ developer by profession.
Thank you all for your time.
Re: "command line"-type PHP interface?
Posted: Wed Jan 05, 2011 3:05 pm
by TalonP
I was just thinking, by "command line," I mean, "console" or "terminal."
I am also not looking for it to perform a Google search or anything like goosh. So I don't think I'll need AJAX or anything. I would be happy right now with a console type PHP page that displays like that and if you type "hello," or something, it would come back with "Hello there!"
Re: "command line"-type PHP interface?
Posted: Wed Jan 05, 2011 4:06 pm
by Jade
Um... PHP is server side only so it's not really the best choice for something like this and you'll need a ton of AJAX or Javascript to get something working. What type of actions are you looking to perform via this "command line"?
Re: "command line"-type PHP interface?
Posted: Thu Jan 06, 2011 7:20 am
by TalonP
Hi, and thanks for the response.
I am aware that PHP is server-side. I figured there would be some kind of HTML front-end. I would be happy with something as simple as:
User types "hey"
and it returns back "hello." I can work from there.
Re: "command line"-type PHP interface?
Posted: Thu Jan 06, 2011 10:21 am
by Jade
Re: "command line"-type PHP interface?
Posted: Thu Jan 06, 2011 11:19 am
by AbraCadaver
AJAX will probably be best, but here is a simple example that would need a lot of work and CSS styling to get it to look/align properly:
Code: Select all
<?php
$output = '';
if(isset($_POST['enter'])) {
$output = $_POST['output'] . "\n" . $_POST['input'] . "\n";
switch($_POST['input']) {
case 'help':
$output .= "You need help!";
break;
case 'clear':
$output = "";
break;
default:
$output .= "Invalid command!";
break;
}
}
?>
<html>
<head>
<title>Test</title>
</head>
<body OnLoad="document.test.input.focus();">
<form name="test" method="post" style="width: 70%; border: 1px solid">
<textarea rows="40" name="output" style="width: 100%; border: none" readonly><?php echo $output; ?></textarea>
<input rows="2" type="text" name="input" style="width: 100%; border: none">
<input type="submit" name="enter" style="visibility: hidden">
</form>
</body>
</html>