<?php
  $one="";
  $two="";
  $three="";
  $four="";
  
  $nextone=1;
  $innards="";
  $title=" ... ";
  
  foreach( $_GET as $name=>$val ) {
    if ($one == "") {
      $one=str_replace("+", " ", urldecode($val));
      $innards.="\nform.append('infld" . $nextone . "', \"" . $val . "\");\n";
      $title.="|" . $val;
      $nextone++;
    } else if ($two == "") {
      $two=str_replace("+", " ", urldecode($val));
      $innards.="\nform.append('infld" . $nextone . "', \"" . $val . "\");\n";
      $title.="|" . $val;
      $nextone++;
    } else if ($three == "") {
      $three=str_replace("+", " ", urldecode($val));
      $innards.="\nform.append('infld" . $nextone . "', \"" . $val . "\");\n";
      $title.="|" . $val;
      $nextone++;
    } else if ($four == "") {
      $four=str_replace("+", " ", urldecode($val));
      $innards.="\nform.append('infld" . $nextone . "', \"" . $val . "\");\n";
      $title.="|" . $val;
      $nextone++;
    } else {
      $one=$two;
      $two=$three;
      $three=$four;
      $four=str_replace("+", " ", urldecode($val));
      $innards.="\nform.append('infld" . $nextone . "', \"" . $val . "\");\n";
      $title.="|" . $val;
      $nextone++;
    }
  }
  
  foreach( $_POST as $name=>$val ) {
    if ($one == "") {
      $one=str_replace("+", " ", urldecode($val));
      $innards.="\nform.append('infld" . $nextone . "', \"" . $val . "\");\n";
      $title.="|" . $val;
      $nextone++;
    } else if ($two == "") {
      $two=str_replace("+", " ", urldecode($val));
      $innards.="\nform.append('infld" . $nextone . "', \"" . $val . "\");\n";
      $title.="|" . $val;
      $nextone++;
    } else if ($three == "") {
      $three=str_replace("+", " ", urldecode($val));
      $innards.="\nform.append('infld" . $nextone . "', \"" . $val . "\");\n";
      $title.="|" . $val;
      $nextone++;
    } else if ($four == "") {
      $four=str_replace("+", " ", urldecode($val));
      $innards.="\nform.append('infld" . $nextone . "', \"" . $val . "\");\n";
      $title.="|" . $val;
      $nextone++;
    } else {
      $one=$two;
      $two=$three;
      $three=$four;
      $four=str_replace("+", " ", urldecode($val));
      $innards.="\nform.append('infld" . $nextone . "', \"" . $val . "\");\n";
      $title.="|" . $val;
      $nextone++;
    }
  }
?>
<?php
  echo "
<!doctype html>
<head>
<title>No Body - RJM Programming - October, 2019" . $title . "</title>
<style>
  html::before {
    border: 2px solid red;
    content: \"" . $one . "\";
	height: 150px;
	width: 90%;
	min-width: 100px;
	background: ivory;
	display: inline-block;
	margin: 0 auto;
	border-radius: 0px 0px 130px 0px;
	margin-top: 50px;
    margin-left: 20px;
	font-size: 60px;
	text-align: center;
  }
  
  body::before {
    border: 2px solid blue;
    content: \"" . $two . "\";
	height: 150px;
	width: 40%;
	min-width: 100px;
	background: ivory;
	display: inline-block;
	margin: 0 auto;
	border-radius: 120px 0px 130px;
	margin-top: 50px;
    margin-left: 20px;
	font-size: 60px;
	text-align: center;
  }
  
  body::after {
    border: 2px solid brown;
    content: \"" . $three . "\";
	height: 150px;
	width: 40%;
	min-width: 100px;
	background: ivory;
	display: inline-block;
	margin: 0 auto;
	border-radius: 120px 0px 130px;
	margin-top: 50px;
    margin-left: 20px;
	font-size: 60px;
	text-align: center;
  }
  
  html::after {
    border: 2px solid purple;
    content: \"" . $four . "\";
	height: 150px;
	width: 90%;
	min-width: 100px;
	background: ivory;
	display: inline-block;
	margin: 0 auto;
	border-radius: 0px 0px 0px 130px;
	margin-top: 50px;
    margin-left: 20px;
	font-size: 60px;
	text-align: center;
  } ";
?>
</style>

<script type='text/javascript'>

  var nextone="<?php echo $nextone; ?>";
  var zhr=null, form=null;
  var nextsb='';
  
  function showStuff(evt) {
  if (zhr.readyState == 4) {
    if (zhr.status == 200) {
      document.title+='|' + nextsb;
      document.write(zhr.responseText);
    }
  }
  }
  
  function donext(nextv) {
  zhr=new XMLHttpRequest();
  form=new FormData();
  <?php
    echo $innards;
  ?>
  form.append('infld' + nextone, nextv);
  zhr.open('post', document.URL, true);
  zhr.onreadystatechange = showStuff;
  zhr.send(form);
  }

  function andthen() {
  nextsb=prompt("Got anything to say?", "");
  if (nextsb == null) { nextsb=""; }
  if (nextsb.trim() != "") {
  donext(nextsb); 
  }
  }

  setTimeout(andthen, eval(nextone * 2000));
</script>
</head>
<!--body>
</body-->
</html>
