O
O
obemgcabazn2020-06-24 11:41:03
PHP
obemgcabazn, 2020-06-24 11:41:03

How to set up CNC on a self-written site in PHP?

I pass the parameter accountName=qwe AJAX to init.php:
$.ajax({
type: 'post',
url: 'init.php',
data: form_data,
success: function (result) {
console.log(result);
}
} );
the request is executed as needed, the variable is written to the database, but the page from index.php comes in the console.log response. In init.php for the test, I left only one function for writing to the database, of this type account_add($db, $name); which only returns true/false (that's what console.log should return)

.htaccess like this


RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


in index.php CNCs are organized like this:

$url = $_SERVER['REQUEST_URI'];
switch ($url) {
case '/':
require_once($app_directory . '/templates/main.php');
break;
case '/accounts/':
require_once($app_directory . '/templates/accounts.php');
break;
}

Why does the page from Index.php end up in console.log?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2020-06-24
@Adamos

Have you tried to read at least one instruction on routing in Apache before writing bicycles?
Add switch
default:
echo "Suddenly, I get the url $url";
and see what it gives you back.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question