Jump to content

Recommended Posts

Hi!

 

I have started a big project with some of my friends.

Its some kind of CMS system.

Now, for quick commands we wanted something like cmd on windows.

Is it possible to build a script that would be something like cmd/a console.

Of course it would be a webpage and not a separate window.

I could do this myself with a input field and a form using the POST method.

But I wouldn't wan't to refresh the page every time I run a command.

So something that works like the input field, form with the POST method, but without needing to refresh every time.

 

Ask if I didn't make it clear enough!

 

Regards

Kevin

Link to comment
https://forums.phpfreaks.com/topic/235711-cmd-made-in-php/
Share on other sites

I did something like this and I didn't want to reload my buttons or text so I used and iframe window as the command window.

 

incubi

 

ok.

 

I have a iFrame now, and another page with the content.

I have made the textarea (log) and but now when I wan't a textline and a button (or to press Enter would be even more nice), how do i do to send the data?

 

Link to comment
https://forums.phpfreaks.com/topic/235711-cmd-made-in-php/#findComment-1211557
Share on other sites

Are you asking that when you press Enter in the textarea the iframe updates or when you press Enter in the textarea the form submits? Pressing Enter in a textarea should insert a line break and that's what the users will expect it to do.

 

incubi

 

I would wan't the Enter press to work the same way as a form posts.

Ex:

Non-iFrame:

two fields, Username and Password, one button "Login"

I enter the Username and Password, and press "Login".

The page sends the data to another page where I check if its right and then redirects...

 

iFrame:

same two fields and button.

This time it doesn't reload any page, it just edits the frame if the login was successful or not.

 

so what I'm trying to say is, I will have one textarea that is a "log" for all content. Then a text field where I can write a command like "Connect to database", wand when I press Enter for example it could run a function called Connect... and then add the text "Connecting" to the "log"..

 

Link to comment
https://forums.phpfreaks.com/topic/235711-cmd-made-in-php/#findComment-1211645
Share on other sites

Hi

 

Here is a update of my project:

Everything works well, I can run commands from the iFrame.

But I need atm to use a button for it.

How can I make "Enter" work as a submit button?

 

EDIT:

How can I make it so that text isn't saved to the textfield every time I submit it.

Ex: I run the command "Create", "Delete", "Time".

Now when I enter something, it suggests all of these because I have entered them before.

Is there somekind of auto save that I can turn of for just this inputfield?

Link to comment
https://forums.phpfreaks.com/topic/235711-cmd-made-in-php/#findComment-1212025
Share on other sites

And now I found another thing I can't understand..

<?php
$log = $_POST['txtLog'];
$command = $_POST['txtCommand'];

$action = "Nothing";
$words = explode(" ",$command);

if(sizeof($words) == 2)
{
if($words[0] == "create")
{
	if($words[1] == "new")
	{
		$action = "LOLOLO";
	}
}
}
// Add text to log
$log = $log . "\n" . $command . " - " . $action;
?>
<html>
<head>
</head>
<body>
<form method="post" action="test3.php">
<textarea cols="100" rows="20" name="txtLog" readonly="yes" style="background: black; color: white; font-family: COURIER;"><?php echo $log; ?>
</textarea>
<input type="text" name="txtCommand" style="background: black; color: white; font-family: COURIER;">
<button type="submit">Run</button>
</form>
</body>
</html>

 

when I input "create new" the output should be "LOLOLO" and it is.

But when I input "ihiuui new" or "create asdasd" the output is still "LOLOLO".

 

How can this be possible?

Link to comment
https://forums.phpfreaks.com/topic/235711-cmd-made-in-php/#findComment-1212040
Share on other sites

i just copied your script directly and tried it on my MAMP server and it works as expected, only echoing lolol when you enter create new.

 

here is cut n paste of the log:

- Nothing

blah new - Nothing

- Nothing

- Nothing

create new - LOLOLO

make new - Nothing

create moo - Nothing

freferf new - Nothing

 

so god knows why you are getting errors!!

Link to comment
https://forums.phpfreaks.com/topic/235711-cmd-made-in-php/#findComment-1212098
Share on other sites

okay the reason that it is saving the data and dropping down when you start typing the command is because this is a feature of your browser and because you are literally submitting the form. the best way to handle this would be with AJAX and with a framework like Jquery would be really easy to make as opposed to an iframe. if you really want to use your current solution add the autocomplete="off" attribute to your form tag.

 

 

Edit: also remember to clear your form data

Link to comment
https://forums.phpfreaks.com/topic/235711-cmd-made-in-php/#findComment-1212119
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.