gpt4 book ai didi

php - wamp 服务器 2.0 在我注销后丢失一条记录

转载 作者:行者123 更新时间:2023-11-29 22:07:23 25 4
gpt4 key购买 nike

我有一个网站,其中有一个用于创建帐户的注册选项。它允许我创建一个帐户,然后登录它。但在我注销并尝试再次登录后,它告诉我用户名和密码无效。 Wamp 数据库似乎正在丢失我注销后创建的记录/帐户。我的其他网站也发生这种情况。我正在使用 Wamp 服务器 2.0 和 Macromedia Dw 8.0。也尝试过 Xampp 但仍然存在同样的问题。该网站主要由 Php 和 Mysql 编码组成。请帮忙。

<?php
$server="localhost";
$user="root";
$pwd="";
$db="GlobalStyling";
$conn=mysql_connect($server,$user,$pwd) or die(mysql_error());
$sql="drop DATABASE $db";
mysql_query($sql);
$sql="CREATE DATABASE GlobalStyling";
$result=mysql_query($sql) or die ("unable to create database");
mysql_select_db($db) or die(mysql_error()."unable to select database");
$query1="Create table members
(
`member_id` int(11) NOT NULL AUTO_INCREMENT,
`firstname` varchar(100) NOT NULL,
`lastname` varchar(100) NOT NULL,
`middlename` varchar(100) NOT NULL,
`address` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`contact_no` varchar(100) NOT NULL,
`age` int(11) NOT NULL,
`gender` varchar(100) NOT NULL,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
PRIMARY KEY (`member_id`)
)";
$query_run=mysql_query($query1);

$query2="Create table note
(
`note_id` int(11) NOT NULL AUTO_INCREMENT,
`date` varchar(100) NOT NULL,
`message` varchar(200) NOT NULL,
PRIMARY KEY (`note_id`)
)";
$query_run=mysql_query($query2);

$query3="Create table schedule
(
`id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` int(11) NOT NULL,
`date` varchar(100) NOT NULL,
`service_id` int(11) NOT NULL,
`Number` int(11) NOT NULL,
`status` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
)";
$query_run=mysql_query($query3);


$query4="Create table service
(
`service_id` int(11) NOT NULL AUTO_INCREMENT,
`service_offer` varchar(100) NOT NULL,
`price` decimal(11,2) NOT NULL,
PRIMARY KEY (`service_id`)
)";
$query_run=mysql_query($query4);
$query5="Create table users
(
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
PRIMARY KEY (`user_id`)
)";
$query_run=mysql_query($query5);
?>
<?php include('header.php'); ?>
<!-- -->
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse"
data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active" ><a rel="tooltip"
data-placement="bottom" title="Home" id="home" href="index.php"
class=""><i
class="icon-home icon-large"></i>&nbsp;Home</a></li>
<li><a rel="tooltip" data-placement="bottom"
title="Services" id="services" href="services.php" class=""><i
class="icon-list icon-large"></i>&nbsp;Services</a></li>
<li><a rel="tooltip" data-placement="bottom"
title="About Us" id="aboutus" href="about.php" class=""><i
class="icon-info
icon-large"></i>&nbsp;About Us</a></li>
<li><a rel="tooltip" data-placement="bottom"
title="Contact Us" id="contactus" href="contact_us.php" class=""><i
class="icon-phone icon-large"></i>&nbsp;Contact US</a></li>

</ul>
<form class="navbar-search pull-right">
<input type="text" class="search-query"
placeholder="Search">
</form>

</div>
</div>
</div>
</div>

<!-- -->
<?php include('dbcon.php'); ?>
<div class="container">
<div class="margin-top">
<div class="row">
<div class="span12">
<?php include('banner.php'); ?>
</div>
<div class="span12">
<div class="caption_index">we provide
the quality dental service</div>
</div>
<div class="clearfix"></div>
<div class="span12">
<?php include('thumbnail.php'); ?>
</div>
<div class="span12">
<?php include('content1.php'); ?>
</div>
<div class="span12">
<?php include('content2.php'); ?>
</div>
</div>
</div>
</div>
<?php include('footer.php') ?>`*

最佳答案

这是一个检查数据库是否存在的示例代码,请注意我使用 mysqli 而不是 mysql,因为 this reason .

<?php
$server = "localhost";
$user = "root";
$pwd = "";
$db = "GlobalStyling";
$conn = mysqli_connect($server, $user, $pwd);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

$dbExists = mysqli_select_db($conn, $db);
// Checking if Database not Exists
if(!$dbExists) {
// Create Database
$sql = "CREATE DATABASE $db";
$result = mysqli_query($conn, $sql) or die(mysqli_error($conn));

// Create Table
mysqli_select_db($conn, $db);
$query1 = "Create table members
(
`member_id` int(11) NOT NULL AUTO_INCREMENT,
`firstname` varchar(100) NOT NULL,
`lastname` varchar(100) NOT NULL,
`middlename` varchar(100) NOT NULL,
`address` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`contact_no` varchar(100) NOT NULL,
`age` int(11) NOT NULL,
`gender` varchar(100) NOT NULL,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
PRIMARY KEY (`member_id`)
)";
$query_run = mysqli_query($conn, $query1);

$query2 = "Create table note
(
`note_id` int(11) NOT NULL AUTO_INCREMENT,
`date` varchar(100) NOT NULL,
`message` varchar(200) NOT NULL,
PRIMARY KEY (`note_id`)
)";
$query_run = mysqli_query($conn, $query2);

$query3 = "Create table schedule
(
`id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` int(11) NOT NULL,
`date` varchar(100) NOT NULL,
`service_id` int(11) NOT NULL,
`Number` int(11) NOT NULL,
`status` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
)";
$query_run = mysqli_query($conn, $query3);

$query4 = "Create table service
(
`service_id` int(11) NOT NULL AUTO_INCREMENT,
`service_offer` varchar(100) NOT NULL,
`price` decimal(11,2) NOT NULL,
PRIMARY KEY (`service_id`)
)";
$query_run = mysqli_query($conn, $query4);

$query5 = "Create table users
(
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
PRIMARY KEY (`user_id`)
)";
$query_run = mysqli_query($conn, $query5);
}
mysqli_close($conn);
?>

示例代码并不是您见过的最漂亮的代码。

关于php - wamp 服务器 2.0 在我注销后丢失一条记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32023652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com