Forum Moderators: coopster

Message Too Old, No Replies

Really stuck with a php form

         

MsCrow

2:54 pm on Aug 28, 2006 (gmt 0)

10+ Year Member



Hello

Many thanks to everyone who helped me with my form. It's mostly working and it's printing to pdf.

My client wants to use lots of these forms, I personally think they are monotonous but there you go. Anyways, a more lengthy version linked below just isn't working, I don't know why, the page jsut does not display.

Cam anyone help before I tear all of my hair out?

Ellie

[edited by: coopster at 3:07 pm (utc) on Aug. 28, 2006]
[edit reason]
[1][edit reason] no urls please TOS [webmasterworld.com] [/edit]
[/edit][/1]

jatar_k

3:13 pm on Aug 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



could you explain what exactly isn't working with the form.

MsCrow

3:22 pm on Aug 28, 2006 (gmt 0)

10+ Year Member



It's not appearing in the browser, there's something in the php, though it looks fine to me, that the page content doesn't load. The link's been removed now, not sure what to do, paste? It's a long page...

jatar_k

3:28 pm on Aug 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if there are no errors then it smells like a parsing error that isn't getting shown

does your site usually show parse errors in the browser?

you could try adding this to the very top of the script

error_reporting(E_ALL);

that may show the error. If we don't know the error then it is difficult to debug.

MsCrow

3:33 pm on Aug 28, 2006 (gmt 0)

10+ Year Member



Maybe it's easier to post the code? You can run away now if you feel like it.

<!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> <script>

function printWindow(){
bV = parseInt(navigator.appVersion)
if (bV >= 4) window.print()
}

</script>

</head>
<body onload="isReady=true">
<a href="#nav" class="skip" accesskey="2">Skip to Content</a>
<div id="container">
<div id="logo"><img src="images/bannerlogos1.jpg" alt="Blue and white logo for section one" width="475" height="32" /></div>
<a name="nav"></a>

<div id="nocolumn">
<h2>How Reflective Are You?</h2>

<p>Try this quiz </p>

<p>For each of the following statements rate the extent to which it applies to you
with 1 = true, 2 = often the case but not always true, 3 = rarely the case, 4 = not true. Add
up your totals and read the section on, &#8217;Interpreting your score&#8217;. Store you results
in your folder.</p>

<?php
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<form method="post" action="<?php echo $PHP_SELF;?>">
<table width="99%" border="0">
<tr>
<td width="80%"><p><strong>Statement</strong></p></td>
<td> <p><strong>Score</strong></p></td>
</tr>
<tr>
<td width="80%"><p>1. I am confident that I will know how to capture and record my own development. </p></td>
<td><input class="form" name="1" wrap="1" type="text" size="5" maxlength="1" /></td>
</tr>
<removed repetetive html -jatar_k>
</tr>
</table>
<input class="form" type="submit" value="submit" name="submit">
</form>
<p class="psmall">&#169; Department of Sociology &amp; ESF </p>
</div>
</div>
<?php
} else {
$1 = $_POST["1"];
$2 = $_POST["2"];
$3 = $_POST["3"];
$4 = $_POST["4"];
$5 = $_POST["5"];
$6 = $_POST["6"];
$7 = $_POST["7"];
$8 = $_POST["8"];
$9 = $_POST["9"];
$10 = $_POST["10"];
$11 = $_POST["11"];
$12 = $_POST["12"];
$13 = $_POST["13"];
$14 = $_POST["14"];
$15 = $_POST["15"];
$16 = $_POST["16"];
$total = $_POST["total"];
echo "<p>answer1:".$1."</p>";
echo "<p>answer2:".$2."</p>";
echo "<p>answer3:".$3."</p>";
echo "<p>answer4:".$4."</p>";
echo "<p>answer5:".$5."</p>";
echo "<p>answer6:".$6."</p>";
echo "<p>answer7:".$7."</p>";
echo "<p>answer8:".$8."</p>";
echo "<p>answer9:".$9."</p>";
echo "<p>answer10:".$10."</p>";
echo "<p>answer11:".$11."</p>";
echo "<p>answer12:".$12."</p>";
echo "<p>answer13:".$13."</p>";
echo "<p>answer14:".$14."</p>";
echo "<p>answer15:".$15."</p>";
echo "<p>answer16:".$16."</p>";
echo "<p>Total - add your score and enter it here:".$total."</p>";
echo "<a href='javascript:printWindow()'><img src='images/print.jpg' height='50' width='45' alt='print this page' border='0' /></a> &nbsp; <a href='intro13pdf.php?1=$1&2=$2&3=$3&4=$4&5=$5&6=$6&7=$7&8=$8&9=$9&10=$10&11=$11&12=$12&13=$13&14=$14&15=$15&16=$16&total=$total'><img src='images/save.jpg' alt='save this page' height='50' width='45' border='0' /></a>";
}
?>

</body>
</html>

[edited by: jatar_k at 3:42 pm (utc) on Aug. 28, 2006]
[edit reason]
[1][edit reason] shortened code [/edit]
[/edit][/1]

jatar_k

3:43 pm on Aug 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try the error bit I posted and then vew source and see if there is anything there that might provide a hint.

jatar_k

3:46 pm on Aug 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well, I just uploaded it to a site of mine

Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /var/www/html/test.php on line 118

you need to get your host to have those errors coming out. display_errors may be set to 'off' and would need to be changed to 'on'

or your error level is set too low, which my code in my first response would fix

you may want to look at this from the manual
[php.net...]

A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

MsCrow

1:17 pm on Aug 29, 2006 (gmt 0)

10+ Year Member



Hello

Yes it was a variables issue, changed them all to words and of course, it worked. Thanks

Just one other query. The form works ok except, the form passes through the form output to fpdf all the text after an apostrophied word just disappears!

In IE, even the print button on output preview doesn't show up - it does in firefox.

[edited by: MsCrow at 1:34 pm (utc) on Aug. 29, 2006]

eelixduppy

1:50 pm on Aug 29, 2006 (gmt 0)



>>>all the text after an apostrophied word just disappears!

Using addslashes [us2.php.net] may fix your problem ;)

Best of luck!

MsCrow

1:58 pm on Aug 29, 2006 (gmt 0)

10+ Year Member



I have checked the magic quotes thing and hosting company said its off, form works ok, it's when it passes through to fpdf and the issue of the print button disappearing. Would addslashes help and if so were would I put it in the code? In the form boxes or the php below?

<?php
} else {
$which = $_POST["which"];
$why = $_POST["why"];
$outline = $_POST["outline"];
$activities = $_POST["activities"];
$extent = $_POST["extent"];
$comments = $_POST["comments"];
echo "<p><b>Which volunteering organisation have you chosen?</b></p><p>".$which."</p>";
echo "<p><b>Why did you choose this volunteering organisation? For example: Have you had previous experience of working in this area? Is the nature of the work, or the aims of the organisation, of relevance to your degree course? Was your decision to work with this organisation related to a career aspiration?</b></p><p>".$why."</p>";
echo "<p><b>Outline briefly your learning objectives for, and expectations of, your volunteering experience. What do you hope to get out of them? How do you expect to achieve them? </b></p><p>".$outline."</p>";
echo "<p><b>What activities do you envisage you will be doing during your volunteering experience?</b></p><p>".$ideas."</p>";
echo "<p><b>Given your objectives and expectations outlined above, to what extent do you think your volunteering experience will allow you to fulfil these expectations?</b></p><p>".$extent."</p>";
echo "<p><b>Any other comments?</b></p><p>".$comments."</p>";
echo "<p>Once you have started your volunteering things may turn out differently. You may not get what you thought you would but you may gain something different. It is best to stick with it and use the experience constructively. If however you have real concerns contact your tutor for advice</p>";
echo "<a href='javascript:printWindow()'><img src='images/print.jpg' height='50' width='45' alt='print this page' border='0' /></a> &nbsp; <a href='focus2pdf.php?which=$which&why=$why&outline=$outline&activities=$activities&extent=$extent&comments=$comments'><img src='images/save.jpg' alt='save this page' height='50' width='45' border='0' /></a>";
}
?>

MsCrow

10:33 pm on Aug 29, 2006 (gmt 0)

10+ Year Member



Hi again

It's something to do with the last line with the variables and ' in the form boxes is effecting it. Can anyone help?

I separated out the code into an html form that posts to the php code above, I was told to use <INPUT TYPE="image" SRC="save.jpg" VALUE="Save" ALT="Save now" NAME="Save"> but it makes no difference or HTTP sockets, but I don't understand those either.

I can't bare looking at this php anymore.

Thanks

jatar_k

4:28 pm on Aug 30, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the problem should then be in focus2pdf.php as opposed to the code you posted

there isn't anything wrong with the code above

you may need to escape quotes or strip them, not sure

can you identify in the file focus2pdf.php where there could be an issue?

MsCrow

10:19 pm on Aug 31, 2006 (gmt 0)

10+ Year Member



Hi Jatar, I decided I had over complicated the issue so stipped out the middle php code, readjusted it to being an html form posting to my fpdf output page and it works since you can either print or save the output file, I still don't know why the button kept disappearing, I guess I never will. Thank you for your time though.

Ellie