we are working with php session data, but the data is not being stored in the database
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` 开发者_C百科('ID', `NAME`) VALUES ('','$name')";
mysql_query($sql);
?>
<a href = "logout.php">Logout</a>
and logout.php
<?php
session_start();
session_destroy();
?>
<a href = "index.php">Click me to return to login </a>
please tell me what's wrong
try displaying the mysql_error and see what the problem is
mysql_query($sql) or die(mysql_error());
精彩评论