I'm setting up a simple form on my local server, but the POST and GET methods both return nothing.
I discovered this problem when making my own form. Then I tried using online tutorial codes to see if they have the same problem, they do. I'm almost sure that it is not the codes problem because of this. When I 'fix' these codes by using isset() or ??'' the resulting page is blank.
Im using Windows 10 x86, PHP 7, node.js local server, code copied from https://www.w3schools.com/php7/php7_forms.asp and https://www.w3resource.com/php/super-variables/$_REQUEST.php .
Does anybody know if there's anything wrong with PHP or is it something else?
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
webserver.js
var express = require('express');
var app = express();
var execPHP = require('./execphp.js')();
execPHP.phpFolder = 'C:\\Users\\Dshop\\Desktop\\php-7.3.3\\Server1';
app.use('*.php',function(request,response,next) {
execPHP.parseFile(request.originalUrl,function(phpResult) {
response.write(phpResult);
response.end();
});
});
app.listen(3000, function () {
console.log('Node server listening on port 3000!');
});
execphp.js
/**
*
*/
class ExecPHP {
/**
*
*/
constructor() {
this.phpPath = 'C:\\Users\\Dshop\\Desktop\\php-7.3.3\\php.exe';
this.phpFolder = '';
}
/**
*
*/
parseFile(fileName,callback) {
var realFileName = this.phpFolder + fileName;
console.log('parsing file: ' + realFileName);
var exec = require('child_process').exec;
var cmd = this.phpPath + ' ' + realFileName;
exec(cmd, function(error, stdout, stderr) {
callback(stdout);
});
}
}
module.exports = function() {
return new ExecPHP();
};
isset()is not a fix it or something similiar is a pre-requisite$_POSTor$_GETarrays actually get filled