用户登录成功后跳转到主页并展示数据库的商品信息

第一步:数据库信息书写

#判断存在即删除数据库
drop database if exists mydb;
#创建数据库
create database mydb;
#使用数据库
use mydb;


#创建表
create table t_user
(
    uid int primary key auto_increment,
    username varchar(20),
    password varchar(20),
    phone varchar(11),
    address varchar(50)
);


insert into t_user(username,password,phone,address) values('张三','666','18965423548','南阳');
insert into t_user(username,password,phone,address) values('李四','333','18754263548','许昌');
insert into t_user(username,password,phone,address) values('小美','123','18565234759','信阳');

select * from t_user where username=? and password=?
select * from t_user;


create table t_goods
(
    gid int primary key auto_increment,
    gname varchar(20),
    price double,
    mark varchar(100)
);

insert into t_goods(gname,price,mark) values('泡面',4.5,'够香够辣就是这个味!');
insert into t_goods(gname,price,mark) values('火腿',8.5,'肉质细腻Q弹!');
insert into t_goods(gname,price,mark) values('雪碧',3.5,'清爽冰凉随心爽!');

select * from t_goods;

第二步:在web中书写HTML 页面 登录,错误页,主页,注册页

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>错误页</title>
</head>
<body>
<h1>出错啦</h1>
<a href="login.jsp">返回登录</a>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>这是第一个Web项目</title>
  </head>
  <body>
 <h1>欢迎来到Web世界</h1>
  <a href="login.jsp">去登录</a>
 <a href="zhuce.jsp">去注册</a>
  </body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
</head>
<body>
<h1>登录</h1>
<form action="login" method="post">
    账号:<input type="text" name="username"value=""/><br/>
    密码:<input type="password" name="password"value=""/><br/>
    <input type="submit" value="登录">
    <a href="zhuce.jsp">没有帐号?请注册</a>
</form>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册</title>
</head>
<body>
<h1>注册</h1>
<form action="zhuce" method="post">
    账号:<input type="t
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值