Jump to content

php web form returns a 40


fopa

Recommended Posts

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

 

1.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2.<html xmlns="http://www.w3.org/1999/xhtml">
3.<head>
4.<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5.<title>This REMOVED</title><br />
6.<style type="text/css">
7.<!--
8..style1 {
9.    font-size: 18px;
10.    font-weight: bold;
11.}
12..style3 {
13.    color: #FFFFFF;
14.    font-weight: bold;
15.}
16..style4 {
17.    color: #84c742;
18.    font-weight: bold;
19.}
20..style5 {color: #84c742}
21..style8 {color: #000000; }
22..style9 {font-weight: bold; font-size: 16px;}
23.-->
24.</style>
25.<br />
26.</head>
27. 
28.<body> <form name "This REMOVED" action="index.php" method="post">
29.<div align="center"><br>
30.<font SIZE="2"></div>
31.<div align="center">
32.  <table width="1044" height="520" border="1" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFCC">
33.    <tr>
34.      <td width="553"><div align="center" class="style8"><span class="style1">Question</span></div></td>
35.      <td width="74" valign="middle"><div align="center" class="style8"><strong>Strongly  Agree</strong></div></td>
36.      <td width="75" valign="middle"><div align="center" class="style8"><strong>Agree</strong></div></td>
37.      <td width="97" valign="middle"><div align="center" class="style8"><strong>Neither  Agree nor Disagree</strong></div></td>
38.      <td width="81" valign="middle"><div align="center" class="style8"><strong>Disagree</strong></div></td>
39.      <td width="120" valign="middle"><div align="center" class="style8"><strong>Strongly  Disagree</strong></div></td>
40.    </tr>
41.    <tr>
42.      <td height="39"><div align="left" class="style8"><span class="style9">Q1:This REMOVED</span></div></td>
43.      <td><div align="center" class="style8">
44.        <input name="This REMOVED" type="radio" value="strongly Agree" />
45.      </div></td>
46.      <td><div align="center" class="style8">
47.        <input name="This REMOVED" type="radio" value="Agree" />
48.      </div></td>
49.      <td><div align="center" class="style8">
50.        <input name="This REMOVED" type="radio" value="Neither Agree nor Disagree" />
51.      </div></td>
52.      <td>
53.        
54.        <div align="center" class="style8">
55.          <input name="This REMOVED" type="radio" value="Disagree" />
56.        </div></td><td><div align="center" class="style8">
57.          <input name="This REMOVED" type="radio" value="Strongly Disagree" />
58.          </div></td>
59.    </tr>
60.    <tr>
61.      <td height="39"><div align="left" class="style8"><span class="style9">Q2: 
62.       This REMOVED</span></div></td>
63.      <td><div align="center" class="style8">
64.        <input name="IThis REMOVED" type="radio" value="strongly Agree" />
65.      </div></td>
66.      <td><div align="center" class="style8">
67.        <input name="This REMOVED" type="radio" value="Agree" />
68.      </div></td>
69.      <td><div align="center" class="style8">
70.        <input name="This REMOVED" type="radio" value="Neither Agree nor Disagree" />
71.      </div></td>
72.      <td>
73.        
74.        <div align="center" class="style8">
75.          <input name="This REMOVED" type="radio" value="Disagree" />
76.        </div></td><td><div align="center" class="style8">
77.          <input name="This REMOVED" type="radio" value="Strongly Disagree" />
78.          </div></td>
79.    </tr>
80.    <tr>
81.      <td height="39"><div align="left" class="style8"><span class="style9">Q3: 
82.        This REMOVED   </span></div></td>
83.      <td><div align="center" class="style8">
84.        <input name="This REMOVED" type="radio" value="strongly Agree" />
85.      </div></td>
86.      <td><div align="center" class="style8">
87.        <input name="This REMOVED" type="radio" value="Agree" />
88.      </div></td>
89.      <td><div align="center" class="style8">
90.        <input name="This REMOVED" type="radio" value="Neither Agree nor Disagree" />
91.      </div></td>
92.      <td>
93.        
94.        <div align="center" class="style8">
95.          <input name="Working here makes me want to do the best I can" type="radio" value="Disagree" />
96.        </div></td><td><div align="center" class="style8">
97.          <input name="Working here makes me want to do the best I can" type="radio" value="Strongly Disagree" />
98.          </div></td>
99.    </tr>
100.    <tr>
101.      <td height="39"><div align="left" class="style8"><span class="style9">Q4: 
102.        This REMOVED   </span></div></td>
103.      <td><div align="center" class="style8">
104.        <input name="This REMOVED" type="radio" value="strongly Agree" />
105.      </div></td>
106.      <td><div align="center" class="style8">
107.        <input name="This REMOVED" type="radio" value="Agree" />
108.      </div></td>
109.      <td><div align="center" class="style8">
110.        <input name="IThis REMOVED" type="radio" value="Neither Agree nor Disagree" />
111.      </div></td>
112.      <td>
113.        
114.        <div align="center" class="style8">
115.          <input name="This REMOVED" type="radio" value="Disagree" />
116.        </div></td><td><div align="center" class="style8">
117.          <input name="This REMOVED" type="radio" value="Strongly Disagree" />
118.          </div></td>
119.    </tr>
120.    <tr>
121.      <td height="42"><div align="left" class="style8"><span class="style9">Q5: This REMOVED</span></div></td>
122.      <td><div align="center" class="style8">
123.        <input name="This REMOVED" type="radio" value="strongly Agree" />
124.      </div></td>
125.      <td><div align="center" class="style8">
126.        <input name="This REMOVED" type="radio" value="Agree" />
127.      </div></td>
128.      <td><div align="center" class="style8">
129.        <input name="This REMOVED" type="radio" value="Neither Agree nor Disagree" />
130.      </div></td>
131.      <td>
132.        
133.        <div align="center" class="style8">
134.          <input name="This REMOVED" type="radio" value="Disagree" />
135.        </div></td><td><div align="center" class="style8">
136.          <input name="This REMOVED" type="radio" value="Strongly Disagree" />
137.          </div></td>
138.    </tr>
139.    <tr>
140.      <td><div align="left" class="style8"><span class="style9">Q6: This company keeps things simple </span></div></td>
141.      <td><div align="center" class="style8">
142.          <input name="This REMOVED" type="radio" value="strongly Agree" />
143.      </div></td>
144.      <td><div align="center" class="style8">
145.          <input name="This REMOVED" type="radio" value="Agree" />
146.      </div></td>
147.      <td><div align="center" class="style8">
148.          <input name="This REMOVED" type="radio" value="Neither Agree nor Disagree" />
149.      </div></td>
150.      <td><div align="center" class="style8">
151.          <input name="This REMOVED" type="radio" value="Disagree" />
152.      </div></td>
153.      <td><div align="center" class="style8">
154.          <input name="This REMOVED" type="radio" value="Strongly Disagree" />
155.      </div></td>
156.    </tr>
157.    <tr>
158.      <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>
159.      <td colspan="5"><span class="style8">
160.        <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>
161.      </span></td>
162.    </tr>
163.    <tr>
164.      <td><div align="left" class="style8"><span class="style9">Q8: What is the best thing about working   here?</span></div></td>
165.      <td colspan="5"><span class="style8">
166.        <textarea name="textarea" cols="75" rows="6" id="textarea"></textarea>
167.      </span></td>
168.    </tr>
169.    <tr>
170.      <td colspan="6">
171.        <label>
172.          <div align="center"><br />
173.            <input type="submit" name="Submit" value="Submit" />
174.          </div>
175.        </label>
176.          <label></label>
177.          <div align="center">
178.            <input name="Clear" type="reset" id="Clear" value=" Clear " />
179.              </div>
180.        </form></td>
181.    </tr>
182.  </table>
183.</div>
184.<p align="center">
185.<table cellspacing="0" cellpadding="0" width="95%" border="0">
186.  <tbody>
187.    <tr>
188.      <td><table id="table2" cellspacing="0" cellpadding="0" width="100%" border="0">
189.        <tbody>
190.          <tr>
191.            <td><h2 align="center">Our Values</h2>
192.                  <hr color="#bdd731" />
193.            </td>
194.          </tr>
195.          <tr>
196.            <td><table id="table8" width="100%" border="1">
197.              <tbody>
198.                <tr>
199.                  <td align="middle" bgcolor="#000000"><div align="center"><span class="style3">put the customer first</span></div></td>
200.                  <td align="middle" bgcolor="#000000"><div align="center" class="style4">treat each other well</div></td>
201.                  <td align="middle" bgcolor="#000000"><div align="center"><span class="style3">keep it simple</span></div></td>
202.                  <td align="middle" bgcolor="#000000"><div align="center"><strong><span class="style5">make a differen</span>ce</strong></div></td>
203.                </tr>
204.              </tbody>
205.            </table></td>
206.          </tr>
207.          <tr>
208.            <td valign="bottom" bordercolorlight="#000000" align="right"> </td>
209.          </tr>
210.        </tbody>
211.      </table></td>
212.    </tr>
213.  </tbody>
214.</table>
215.</body>
216.</html>

 

and the php code

 

1.<?php
2.# ----------------------------------------------------
3.# -----
4.# ----- This script was generated by php form magic 1.1 on 03/06/2009 at 16:02:31
5.# -----
6.# ----- http://www.websitedatabases.com7.# -----
8.# ----------------------------------------------------
9. 
10. 
11.// Receiving variables
12.@$I am proud to work for *** = addslashes($_POST['I am proud to work for ***');
13.@$I feel a strong sense of belonging to **** = addslashes($_POST['I feel a strong sense of belonging to ****']);
14.@$Working here makes me want to do the best I can = addslashes($_POST['Working here makes me want to do the best I can']);
15.@$I intend to be working for ****time = addslashes($_POST['I intend to be working for ****time']);
16.@$Considering everything, I am satisfied to be  working for the *** = addslashes($_POST['Considering everything, I am satisfied to be  working for ***']);
17.@$This company keeps things simple = addslashes($_POST['This company keeps things simple']);
18.@$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?']);
19.@$textarea = addslashes($_POST['textarea']);
20. 
21.// Validation
22.//saving record in a text file
23.$pfw_file_name = "data.csv";
24.$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";
25.$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";
26.$pfw_is_first_row = false;
27.if(!file_exists($pfw_file_name))
28.{
29. $pfw_is_first_row = true ;
30.}
31.if (!$pfw_handle = fopen($pfw_file_name, 'a+')) {
32. die("Cannot open file ($pfw_file_name)");
33. exit;
34.}
35.if ($pfw_is_first_row)
36.{
37.  if (fwrite($pfw_handle, $pfw_first_raw ) === FALSE) {
38.  die("Cannot write to file ($pfw_filename)");
39.  exit;
40.  }
41.}
42.if (fwrite($pfw_handle, $pfw_values) === FALSE) {
43.  die("Cannot write to file ($pfw_filename)");
44.  exit;
45.}
46.fclose($pfw_handle);
47. 
48. echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>work</font></p>");
49.?>
50. 

 

I have sinced replaced the radio buttons value spaces with and underscore, i have also tried renaming the php file, but it still results in a 404, any ideas?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/160902-php-web-form-returns-a-40/
Share on other sites

<form name "This REMOVED" action="index.php" method="post">

 

name doesn't have an equals '=' sign

 

<input name="This REMOVED" type="radio" value="Neither Agree nor Disagree" />

 

none of your input fields have 'proper' names assigned (the names are used by php)

 

@$I am proud to work for *** = addslashes($_POST['I am proud to work for ***');

 

That's basically jibberish;

 

$your_variable = addslashes($_POST['the-name-you-set-in-the-form']);

 

$pfw_values = "$I am proud to work for ***,$I feel a strong sense of belonging ***,......

 

you need to put the variables you assign in there.

 

I've never used php magic form, either you've used it 'wrongly' or it's just shit....

The stars and removed etc i put in place to protect the identity of the company i work for, sorry i am not conversant with php at all, hence my posting here.

 

I shall remove the = as suggested

 

the input fields are radio buttons should i simply rename them as R1 and so forth?

 

and thanks for taking the time to reply, is it much appreciated.

 

I shall remove the = as suggested

 

You can't remove it, as it isn't there, that's the problem (you need it)

 

the input fields are radio buttons should i simply rename them as R1 and so forth?

 

You name them whatever you want. Something descriptive is always good, something you'll understand

I shall remove the = as suggested

 

You can't remove it, as it isn't there, that's the problem (you need it)

 

the input fields are radio buttons should i simply rename them as R1 and so forth?

 

You name them whatever you want. Something descriptive is always good, something you'll understand

ok i shall give that a try, Is there an easy alternative out there which would simply convert my form to php for use?

I agree the tutorials are the way forward, but i have very limited time to not just learn php, but to code it correctly for the data to be sent to a flat file, so bundled solutions seems the bet bet.

 

I cant help but feeling its a server issue also, the mailto function works fine on the html form and a very simple form will not outpuit in php.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.