0

Recently, my employer's server was upgraded from PHP 4 to version 7. Their site has a PHP form that relied on PHP 4, but now it doesn't process submissions after the upgrade to PHP 7.

Below is the code for posting the submission to the Java servlet:

 //check required fields
$all_required = $company_req . $firstname_req . $lastname_req . $title_req . $phone_req . $email_req ;
$request = $request . $all_required;
if   ($request == 'y')
   {
   //post to taskflow servlet
   $ar['key']='value';
   foreach($_POST as $key=>$value)
   {
   $postvars.=$key. '=' . urlencode($value) . '&';
   $posted_data[$key]=$value;
   }
   $postvars=trim($postvars,'&');
   $errstr=$errno='';
   $fp= @ fsockopen('www.task-manager.net',80,$errno,$errstr,30);
   if(!$fp)
   {
   $posted_data['error']="fsockopen error no. $errno: $errstr";
   log_results(0);
   die();
   }
   @ fputs($fp, "POST /Taskflow/servlet/INFOREQSAVE http/1.1\r\n");
   @ fputs($fp, "Host: $host\r\n");
   @ fputs($fp, "User-Agent: Mozilla/5.0\r\n");
   @ fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
   @ fputs($fp, "Content-length: ".strlen($postvars)."\r\n");
   @ fputs($fp, "Connection: close\r\n\r\n");
   @ fputs($fp, $postvars . "\r\n\r\n");
   $str='';
   while(!feof($fp))
   $str.=@ fgets($fp,1024);
   @ fclose($fp);
   //send thankyou page
   header('Location:http://www.company-domain.com/thankyou.shtml'...);
   }
else //update and send contact page
   include 'contact.inc.top.html';

How do I get this to work with PHP 7?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 1
    Are you getting any errors in the logs? Are you getting any sort of response back? You might actually want to try using curl instead of writing the socket yourself. – aynber Dec 01 '17 at 18:19
  • Yes, I have "undefined variable" and "undefined index" errors in error log. – pinecreativelabs Dec 01 '17 at 19:01

0 Answers0