php web form returns a 404

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fopa
Forum Newbie
Posts: 7
Joined: Thu Jun 04, 2009 3:37 am

php web form returns a 404

Post by fopa »

I have had to work on a web form which is due to go live tomorrow and normally the results of the form would be mailed so i would as a rule just use HTML. However the requirement was for data to be stored to a flat file, in either CSV or txt. I dont really know much PHP but it was already conifgured on the server for a joomla installatiion.

I created my form and used php magic form to generate the php file, however on submit it takes me to a 404 page, both files are in the same directory and i am really at a loss as to what to do next i am desperate to get this resolved today, or im for the high jump 8O
fopa
Forum Newbie
Posts: 7
Joined: Thu Jun 04, 2009 3:37 am

Re: php web form returns a 404

Post by fopa »

Sorry for some reason the files have not attached to the op

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>This REMOVED</title><br />
<style type="text/css">
<!--
.style1 {
    font-size: 18px;
    font-weight: bold;
}
.style3 {
    color: #FFFFFF;
    font-weight: bold;
}
.style4 {
    color: #84c742;
    font-weight: bold;
}
.style5 {color: #84c742}
.style8 {color: #000000; }
.style9 {font-weight: bold; font-size: 16px;}
-->
</style>
<br />
</head>
 
<body> <form name "This REMOVED" action="index.php" method="post">
<div align="center"><br>
<font SIZE="2"></div>
<div align="center">
  <table width="1044" height="520" border="1" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFCC">
    <tr>
      <td width="553"><div align="center" class="style8"><span class="style1">Question</span></div></td>
      <td width="74" valign="middle"><div align="center" class="style8"><strong>Strongly  Agree</strong></div></td>
      <td width="75" valign="middle"><div align="center" class="style8"><strong>Agree</strong></div></td>
      <td width="97" valign="middle"><div align="center" class="style8"><strong>Neither  Agree nor Disagree</strong></div></td>
      <td width="81" valign="middle"><div align="center" class="style8"><strong>Disagree</strong></div></td>
      <td width="120" valign="middle"><div align="center" class="style8"><strong>Strongly  Disagree</strong></div></td>
    </tr>
    <tr>
      <td height="39"><div align="left" class="style8"><span class="style9">Q1:This REMOVED</span></div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="strongly Agree" />
      </div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="Agree" />
      </div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="Neither Agree nor Disagree" />
      </div></td>
      <td>
        
        <div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Disagree" />
        </div></td><td><div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Strongly Disagree" />
          </div></td>
    </tr>
    <tr>
      <td height="39"><div align="left" class="style8"><span class="style9">Q2: 
       This REMOVED</span></div></td>
      <td><div align="center" class="style8">
        <input name="IThis REMOVED" type="radio" value="strongly Agree" />
      </div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="Agree" />
      </div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="Neither Agree nor Disagree" />
      </div></td>
      <td>
        
        <div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Disagree" />
        </div></td><td><div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Strongly Disagree" />
          </div></td>
    </tr>
    <tr>
      <td height="39"><div align="left" class="style8"><span class="style9">Q3: 
        This REMOVED   </span></div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="strongly Agree" />
      </div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="Agree" />
      </div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="Neither Agree nor Disagree" />
      </div></td>
      <td>
        
        <div align="center" class="style8">
          <input name="Working here makes me want to do the best I can" type="radio" value="Disagree" />
        </div></td><td><div align="center" class="style8">
          <input name="Working here makes me want to do the best I can" type="radio" value="Strongly Disagree" />
          </div></td>
    </tr>
    <tr>
      <td height="39"><div align="left" class="style8"><span class="style9">Q4: 
        This REMOVED   </span></div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="strongly Agree" />
      </div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="Agree" />
      </div></td>
      <td><div align="center" class="style8">
        <input name="IThis REMOVED" type="radio" value="Neither Agree nor Disagree" />
      </div></td>
      <td>
        
        <div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Disagree" />
        </div></td><td><div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Strongly Disagree" />
          </div></td>
    </tr>
    <tr>
      <td height="42"><div align="left" class="style8"><span class="style9">Q5: This REMOVED</span></div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="strongly Agree" />
      </div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="Agree" />
      </div></td>
      <td><div align="center" class="style8">
        <input name="This REMOVED" type="radio" value="Neither Agree nor Disagree" />
      </div></td>
      <td>
        
        <div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Disagree" />
        </div></td><td><div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Strongly Disagree" />
          </div></td>
    </tr>
    <tr>
      <td><div align="left" class="style8"><span class="style9">Q6: This company keeps things simple </span></div></td>
      <td><div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="strongly Agree" />
      </div></td>
      <td><div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Agree" />
      </div></td>
      <td><div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Neither Agree nor Disagree" />
      </div></td>
      <td><div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Disagree" />
      </div></td>
      <td><div align="center" class="style8">
          <input name="This REMOVED" type="radio" value="Strongly Disagree" />
      </div></td>
    </tr>
    <tr>
      <td height="93"><div align="left" class="style8"><span class="style9">Q7: If you could change one thing about working for REMOVED, what would it be?</span></div></td>
      <td colspan="5"><span class="style8">
        <textarea name="If you could change one thing about working for REMOVED, what would it be?" cols="75" rows="6" id="If you could change one thing about working REMOVED, what would it be?"></textarea>
      </span></td>
    </tr>
    <tr>
      <td><div align="left" class="style8"><span class="style9">Q8: What is the best thing about working   here?</span></div></td>
      <td colspan="5"><span class="style8">
        <textarea name="textarea" cols="75" rows="6" id="textarea"></textarea>
      </span></td>
    </tr>
    <tr>
      <td colspan="6">
        <label>
          <div align="center"><br />
            <input type="submit" name="Submit" value="Submit" />
          </div>
        </label>
          <label></label>
          <div align="center">
            <input name="Clear" type="reset" id="Clear" value=" Clear " />
              </div>
        </form></td>
    </tr>
  </table>
</div>
<p align="center">
<table cellspacing="0" cellpadding="0" width="95%" border="0">
  <tbody>
    <tr>
      <td><table id="table2" cellspacing="0" cellpadding="0" width="100%" border="0">
        <tbody>
          <tr>
            <td><h2 align="center">Our Values</h2>
                  <hr color="#bdd731" />
            </td>
          </tr>
          <tr>
            <td><table id="table8" width="100%" border="1">
              <tbody>
                <tr>
                  <td align="middle" bgcolor="#000000"><div align="center"><span class="style3">put the customer first</span></div></td>
                  <td align="middle" bgcolor="#000000"><div align="center" class="style4">treat each other well</div></td>
                  <td align="middle" bgcolor="#000000"><div align="center"><span class="style3">keep it simple</span></div></td>
                  <td align="middle" bgcolor="#000000"><div align="center"><strong><span class="style5">make a differen</span>ce</strong></div></td>
                </tr>
              </tbody>
            </table></td>
          </tr>
          <tr>
            <td valign="bottom" bordercolorlight="#000000" align="right">&nbsp;</td>
          </tr>
        </tbody>
      </table></td>
    </tr>
  </tbody>
</table>
</body>
</html>
 

The PHP code

Code: Select all

<?php
# ----------------------------------------------------
# -----
# ----- This script was generated by php form magic 1.1 on 03/06/2009 at 16:02:31
# -----
# ----- http://www.websitedatabases.com
# -----
# ----------------------------------------------------
 
 
// Receiving variables
@$I am proud to work for *** = addslashes($_POST['I am proud to work for ***');
@$I feel a strong sense of belonging to **** = addslashes($_POST['I feel a strong sense of belonging to ****']);
@$Working here makes me want to do the best I can = addslashes($_POST['Working here makes me want to do the best I can']);
@$I intend to be working for ****time = addslashes($_POST['I intend to be working for ****time']);
@$Considering everything, I am satisfied to be  working for the *** = addslashes($_POST['Considering everything, I am satisfied to be  working for ***']);
@$This company keeps things simple = addslashes($_POST['This company keeps things simple']);
@$If you could change one thing about working for ***, what would it be? = addslashes($_POST['If you could change one thing about ****, what would it be?']);
@$textarea = addslashes($_POST['textarea']);
 
// Validation
//saving record in a text file
$pfw_file_name = "data.csv";
$pfw_first_raw = "I am ****,I feel a strong ****,Working here makes me want to do the best I can,I intend to ***months time,Considering everything, I am satisfied to be  working for ***,This company keeps things simple,If you could change one thing about ***, what would it be?,textarea\n";
$pfw_values = "$I am proud to work for ***,$I feel a strong sense of belonging ***,$Working here makes me want to do the best I can,$I intend to be working for **** time,$This REMOVED,$This REMOVED,".str_replace ("\r\n","<BR>",$This REMOVED? ).",".str_replace ("\r\n","<BR>",$textarea )."\n";
$pfw_is_first_row = false;
if(!file_exists($pfw_file_name))
{
 $pfw_is_first_row = true ;
}
if (!$pfw_handle = fopen($pfw_file_name, 'a+')) {
 die("Cannot open file ($pfw_file_name)");
 exit;
}
if ($pfw_is_first_row)
{
  if (fwrite($pfw_handle, $pfw_first_raw ) === FALSE) {
  die("Cannot write to file ($pfw_filename)");
  exit;
  }
}
if (fwrite($pfw_handle, $pfw_values) === FALSE) {
  die("Cannot write to file ($pfw_filename)");
  exit;
}
fclose($pfw_handle);
 
 echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>work</font></p>");
?>
 
fopa
Forum Newbie
Posts: 7
Joined: Thu Jun 04, 2009 3:37 am

Re: php web form returns a 404

Post by fopa »

in the HTML form data i renamed the radio values to remove the space and added an underscore...
Post Reply