I am not exactly sure how to word this question so bare with me but basically i am creating site for users where they will be able to upload 'test.php' file to there own server and it will display a support form. Now my problem is whenever they submit form, I can't get the form input values. Whenever I use $_POST['subject'] it returns empty.
Here is 'test.php' file:
Here is the form file 'ex1.php':
Here is 'test.php' file:
PHP:
<?php
header("Cache-Control: max-age=0, private, no-cache, no-store, must-revalidate");
define("APIKEY","APIKEY-2893-0889-2351-2804");
define("FILE_NAME","ex1.php");
define("GET_PARAM","online");
function getdomain(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://example.com/api');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 400);
$domain = curl_exec($ch);
if(filter_var(gethostbyname($domain), FILTER_VALIDATE_IP)){
return $domain;
}
else{
$domain = 'example.com/api';
return $domain;
}
}
function sendRequest($post_data) {
$CURLOPT_URL = 'https://' . getdomain()."/".FILE_NAME;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $CURLOPT_URL);
curl_setopt($ch, CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 400);
$x = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
if ($x == '403'){
return header('HTTP/1.0 403 Forbidden');
}elseif($x == "404"){
return header('HTTP/1.0 404 Not Found');
}else{
return $x;
}
}
if (isset($_GET[GET_PARAM])) {
$token = $_GET[GET_PARAM];
$post_data = [
'apikey' => APIKEY,
'token' => $token,
];
echo sendRequest($post_data);
}else{
header('HTTP/1.0 403 Forbidden', true, 404);
exit();
}
?>
Here is the form file 'ex1.php':
Code:
<form action="" method="POST">
<div class="form-group">
<label for="">Subject</label>
<input type="text" name="subject" placeholder="Enter Subject" required>
</div>
<div class="form-group">
<label for="">Message</label>
<textarea name="message" placeholder="Describe issue..." required></textarea>
</div>
</form>