PHP form komut dosyası masaüstünde çalışır, ancak sunucuda

0 Cevap

Stumped. PHP temel bir form yapıyorum, ve Ubuntu 10.04 masaüstü yüklemek bir hisse senedi üzerinde mükemmel çalışır, ancak, bildiğim kadarıyla gördüğünüz gibi, yapılandırma açısından belirgin farklılıklar Ubuntu 9.10 kullanan web sunucusu üzerinde çalışırken başarısız olur.

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:

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
    }
}

Beklendiği gibi masaüstünde, Gönder tuşuna basarak yeni bir formu her zaman sunulması, tablodaki tüm öğeler arasında, götürür. Ancak sunucu üzerinde, Gönder tuşuna basarak boş bir sayfa üretir ve beklenen yeni form görüntülenir Geri düğmesine bastığınızda sadece.

Eğer radyo düğmesine basın ve ardından Gönder zaman masaüstünde, hata mesajı kaybolur, ancak sunucu üzerinde o zamanlar kullanılmış ise görünen tutmak gibi görünüyor.

Bu muhtemelen basit bir şey, ama ben sadece neden herkes kör edici açık ise, bana sefalet koyun lütfen. Daha :-( düz herhangi göremiyorum.

Update:

Tamam - Burada sayfasında (opinions.php) için kod:

<?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="1"></td>';
    echo '<td width="200" class="ratings">Sometimes<input type="radio" name="opinion" value="2"></td>';
    echo '<td width="200" class="ratings">Often<input type="radio" name="opinion" value="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="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");
?>

header.php ve footer.php sadece sayfa mobilya içerir.

0 Cevap