title: How to create a file based on form using fopen() and variable from form $value?
body: <p>I have been using this form script for a years now, however for some time have not checked it and seems it is no longer working.</p>
  
  <p>Pasting simplified version, not sure how to proceed with it in PHP5, as in the past it was working correctly.</p>
  
  <p>In the form, users is typing in one field his/her name and then when submitting, script should create a file called "save his/her name.html", however when submitting, server receives a file "save  .html" with every $value not filled.</p>
  
  <p>My server currently has PHP 5.4.45 installed, have tried on past PHP5 versions as well as on PHP7 with no luck.</p>
  
  <p>Also tried few $_POST options, however with no luck, so pasting over last known working version.</p>
  
  <p>FORM PHP FILE</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;
  &lt;meta http-equiv='Content-Type' CONTENT='text/html; charset=utf-8'&gt;
  &lt;meta name='GENERATOR'&gt;
  &lt;meta name='ProgId'&gt;
  &lt;title&gt;Save form&lt;/title&gt;
  &lt;SCRIPT&gt;
  function makevisible(cur,which){
  if (which==0)
  cur.filters.alpha.opacity=100
  else
  cur.filters.alpha.opacity=50
  }
  &lt;/SCRIPT&gt;
  &lt;style type='text/css' rel='StyleSheet'&gt;
  A:link {
         COLOR: White; TEXT-DECORATION: none
  }
  A:visited {
         COLOR: White; TEXT-DECORATION: none
  }
  A:active {
         COLOR: White; TEXT-DECORATION: none
  }
  A:hover {
         COLOR: White; TEXT-DECORATION: underline
  }
  P {
         FONT-SIZE: 10px; COLOR: White; FONT-FAMILY: Verdana; TEXT-DECORATION: none
  }
  B {
         FONT-SIZE: 10px; COLOR: White; FONT-FAMILY: Verdana; TEXT-DECORATION: none
  }
  TD {
         FONT-SIZE: 10px; COLOR: White; FONT-FAMILY: Verdana; TEXT-DECORATION: none
  }
  BODY {
         FONT-FAMILY: Verdana; FONT-SIZE: 10px; MARGIN: 0px; PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
  }
  --&gt;&lt;/style&gt;
  
  &lt;/head&gt;
  &lt;body bgcolor='#00500B'&gt;
  
  &lt;p&gt;Please fill the form&lt;/p&gt;
  
  &lt;form action="save.php" method="post" enctype="multipart/form-data"&gt;
    &lt;table width='100%'&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td width='478' height='25'&gt;Player:&lt;br&gt;
            &lt;p&gt;&amp;nbsp;&lt;/p&gt;
          &lt;/td&gt;
          &lt;td vAlign='top' width='278' height='24'&gt;&lt;input name='player' id='player' size='20'&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
          &lt;td width='478' height='25'&gt;Character:&lt;br&gt;
            &lt;p&gt;&amp;nbsp;&lt;/p&gt;
          &lt;/td&gt;
          &lt;td vAlign='top' width='278' height='24'&gt;&lt;input type="text" name="charactername" id="charactername" size='20'&gt;&lt;/td&gt;
          &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td width='478' height='25'&gt;Type:
            &lt;p&gt;&amp;nbsp;&lt;/p&gt;
          &lt;/td&gt;
          &lt;td vAlign='top' width='278' height='25'&gt;&lt;select size='1' name='type' id='type'&gt;
              &lt;option value='type1' selected&gt;Type one&lt;/option&gt;
              &lt;option value='type2'&gt;Type two&lt;/option&gt;
            &lt;/select&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td width='692' colSpan='2' height='20'&gt;
            &lt;p align='center'&gt;&lt;br&gt;
            &lt;input type='submit' value='Submit the form'&gt;&lt;br&gt;
            &lt;/p&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
        &lt;/FORM&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  
  &lt;/html&gt;
  
  </code></pre>
  
  <p>SAVE.PHP script that should create a file:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" CONTENT="text/html; charset=utf-8"&gt;
  &lt;meta name="GENERATOR" content="Microsoft FrontPage 4.0"&gt;
  &lt;meta name="ProgId" content="FrontPage.Editor.Document"&gt;
  &lt;title&gt;Page Title&lt;/title&gt;
  &lt;style type="text/css" rel="StyleSheet"&gt;
  A:link {
         COLOR: #FFFFFF; TEXT-DECORATION: none
  }
  A:visited {
         COLOR: #FFFFFF; TEXT-DECORATION: none
  }
  A:active {
         COLOR: #FFFFFF; TEXT-DECORATION: none
  }
  A:hover {
         COLOR: #FFFFFF; TEXT-DECORATION: underline
  }
  P {
         FONT-SIZE: 10px; COLOR: #FFFFFF; FONT-FAMILY: Verdana; TEXT-DECORATION: none
  }
  B {
         FONT-SIZE: 10px; COLOR: #FFFFFF; FONT-FAMILY: Verdana; TEXT-DECORATION: none
  }
  TD {
         FONT-SIZE: 10px; COLOR: #FFFFFF; FONT-FAMILY: Verdana; TEXT-DECORATION: none
  }
  BODY {
         FONT-FAMILY: Verdana; FONT-SIZE: 10px; MARGIN: 0px; PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
  }
  --&gt;&lt;/style&gt;
  
  &lt;/head&gt;
  &lt;?
  $file = fopen("save $charactername.html","w");
  $a="
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Page title&lt;/title&gt;
  &lt;meta http-equiv='Content-Type' CONTENT='text/html; charset=utf-8'&gt;
  
  &lt;style type='text/css'&gt; 
  &lt;!-- 
  
  div#menu { padding-left: 4px; color: #FFFFFF; float: center; font-family: Verdana; margin-right: 0px; font-size: 10px; } 
  
  div#menu a { padding-left: 4px; text-decoration: none; font-family: Verdana; color: #FFFFFF; padding: 1px; margin-top: 0px; width: 100px; } 
  
  div#menu a:hover { color: #C0C0C0; font-family: Verdana; } 
  
  div#text { padding-left: 3px; padding-right: 3px; padding-top: 3px; float: center; font-family: Verdana; text-size: 9px; font-size: 10px; text-decoration: none; color: #FFFFFF; }
  
  div#text a { color: #FFFFFF; }
  
  div#text a:hover { color: #C0C0C0; }
  
  div#title { font-weight: bold; padding-left: 10px; float: center; margin-right: 4px; font-family: Verdana; text-size: 9px; font-size: 10px; text-decoration: none; color: #FFFFFF; }
  
  div#title { font-weight: bold; padding-left: 65px; float: center; margin-right: 4px; font-family: Verdana; text-size: 9px; font-size: 10px; text-decoration: none; color: #FFFFFF; }
  
  --&gt; 
  &lt;/style&gt;
  &lt;/HEAD&gt;
  &lt;html&gt;
  &lt;body bottommargin='0' leftmargin='0' topmargin='0' style='cursor:crosshair; background-color:#000B26; color:#999500' bgcolor='#000B26'&gt;
  &lt;center&gt;
      &lt;table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='300' height='500' id='text' background='$type.jpg'&gt;
          &lt;tr&gt;
              &lt;td rowspan='6' width='25'&gt;&amp;nbsp;&lt;/td&gt;
              &lt;td width='250' height='24' colspan='2' valign='top'&gt;
                      &lt;center&gt;
                          &lt;div id='text'&gt;
                              &lt;b&gt;Player&lt;/b&gt;: $player &amp;nbsp;&amp;nbsp; 
                              &lt;b&gt;Character&lt;/b&gt;: $charactername
                          &lt;/div&gt;
                      &lt;/center&gt;
              &lt;/td&gt;
              &lt;td rowspan='6' width='25'&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/center&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  ";
  fputs($file,"$a\n");
  fclose($file);
  print('Save has been sent to server. Thank you');
  ?&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Are you able to advise how to change/repair the code, so that it would:
  1. create a file with correct file name
  2. have all variable $ filled in created file as per User's input.</p>