PHP表单,会话数据未存储

时间:2011-08-31 03:30:12

标签: php mysql database session

我们正在使用php会话数据,但数据没有存储在数据库中

的login.php

<h2>Welcome</h2>
<form action = "Customer.php" method = "POST">
 Customer Name:<input type = "text" name="customerName">
 <input type = "submit" name = "submit">
</form> 

Customer.php

<?php 

session_start(); 
#include("Connection.php);

if (isset($_POST['submit'])) { 
    $name = $_POST['customerName']; 
    $_SESSION['user'] = $name; 
} 
if (isset($_SESSION['user'])) 
{ 
    echo "Hello {$_SESSION['user']}, welcome to starbucks!"; 
}
else
{
    echo "walang tao";
    $sql="INSERT INTO  `customer`.`people` ('ID', `NAME`) VALUES ('','$name')";
    mysql_query($sql);
?>
<a href = "logout.php">Logout</a>

和logout.php

<?php

session_start();
session_destroy();

?>

<a href = "index.php">Click me to return to login </a>

请告诉我出了什么问题

1 个答案:

答案 0 :(得分:1)

尝试显示mysql_error,看看问题是什么

mysql_query($sql) or die(mysql_error());