PHP form script works on desktop, but not on server

smallville

New Member
I'm stumped. I'm doing a basic form in PHP, and it works perfectly on a stock Ubuntu 10.04 desktop install, but fails when running on the webserver, which is using Ubuntu 9.10 with, as far as I can see, no obvious differences in configuration.A session variable ($_SESSION['id']) is set to 1 on the previous page, and then the script consists of:
(1) session_start();
(2) An SQL query to pull a record out of the db table based on the session value of id (select * from products where id=$_SESSION['id'])
(3) A function to print out the form itself, with an error message if necessary. The form is just a few radio buttons named "opinion", with an error message for use if none of them has been pressed.
(4) The code:\[code\]if (!isset($_POST['submit']))// if the Submit button has not been pressed ...{ showpage($error=false); // ... show the form}else{ if (!isset($_POST['opinion'])) // if Submit was pressed, but no radio button ... { showpage($error=true); // ... reprint the form with the error message } else // if both radio button and Submit were pressed { $_SESSION['id']=$_SESSION['id']+1; // increment the session variable $_SESSION['opinion']=$_POST['opinion']; // convert the radio button value into a session variable header("Location: myratings.php"); // present a new page which will be based on the incremented id }}\[/code\]On the desktop, pressing Submit takes you, as expected, through all the items in the table, presenting a new form each time. But on the server, pressing Submit produces a blank page, and it is only when you press the Back button that the expected new form appears.On the desktop, the error message disappears when you press the radio button and then Submit, but on the server it seems to keep appearing if it has been used once.This is probably something simple, but I just can't see straight any more :-(. If the reason is blindingly obvious to anyone, please put me out of my misery.Update:OK - here's the code for the page (opinions.php):\[code\]<?php session_start();header("Content-type: text/html; charset=utf-8");include("includes/header.php");$id=$_SESSION['id'];$sql="select * from products where id=$id";$result=pg_query($db_handle,$sql) or die("Can't get the items");while ($row=pg_fetch_object($result)){ $id=$row->id; $product=$row->product;}function showpage($product, $error=false){ echo '<form action="opinions.php" method="POST">'; echo '<table width="600" align="center">'; echo '<tr><td colspan="3" class="ratings"><h3>How often would you use $product?</h3></td></tr>'; echo '<tr>'; echo '<td width="200" class="ratings">Never<input type="radio" name="opinion" value="http://stackoverflow.com/questions/3826439/1"></td>'; echo '<td width="200" class="ratings">Sometimes<input type="radio" name="opinion" value="http://stackoverflow.com/questions/3826439/2"></td>'; echo '<td width="200" class="ratings">Often<input type="radio" name="opinion" value="http://stackoverflow.com/questions/3826439/3"></td>'; echo '</tr>'; if ($error) {echo '<tr><td colspan="3" class="ratingserror">Please press a raddio button!</td></tr>';} echo '<tr><td colspan="3" class="ratings"><input type="submit" name="submit" value="http://stackoverflow.com/questions/3826439/Continue"></td></tr>'; echo '</table>'; echo '</form>';}if (!isset($_POST['submit'])) { showpage($product, $error=false);}else{ if (!isset($_POST['opinion'])) { showpage($product, $error=true); } else { $_SESSION['id']=$_SESSION['id']+1; header("Location: opinions.php"); }}include("includes/footer.php");?>\[/code\]header.php and footer.php just contain page furniture.
 
Back
Top