导航:首页 > 源码编译 > 注册登录跳转主页源码

注册登录跳转主页源码

发布时间:2023-10-24 05:57:29

㈠ 求php实现登录成功后返回首页并在原登录处显示用户名的源代码(类似于铁血网的登录)

<?php
session_start();//用SESSION记录模式,并开启。
//用户登录信息,并记录
if(@$_POST['GoLog']){
$_SESSION['user']=@$_POST['login'];
}
//主页的检查用户登录与否,并显示欢迎信息
if(@$_SESSION['user']==''){
echo"目前没有登录";
}else{
echo$_SESSION['user']."欢迎你的回来!";
}
?>
<formaction=''method='post'>
<inputtype='text'name='login'/>
<inputtype='submit'name='GoLog'value='登录'/>
</form>

我只是给你写了个原理,你可以加入更多的判断。

㈡ jsp登陆界面源代码

login.jsp文件

<%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%>

<%@ page import="java.util.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>登录页面</title>

</head>

<body>

<form name="loginForm" method="post" action="judgeUser.jsp">

<table>

<tr>

<td>用户名:<input type="text" name="userName" id="userName"></td>

</tr>

<tr>

<td>密码:<input type="password" name="password" id="password"></td>

</tr>

<tr>

<td><input type="submit" value="登录" style="background-color:pink"> <input

type="reset" value="重置" style="background-color:red"></td>

</tr>

</table>

</form>

</body>

</html>

Data_uil.java文件代码:

import java.sql.*;

public class Data_uil

{

public Connection getConnection()

{

try{

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

}catch(ClassNotFoundException e)

{

e.printStackTrace();

}

String user="***";

String password="***";

String url="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=***";

Connection con=null;

try{

con=DriverManager.getConnection(url,user,password);

}catch(SQLException e)

{

e.printStackTrace();

}

return con;

}

public String selectPassword(String username)

{

Connection connection=getConnection();

String sql="select *from login where username=?";

PreparedStatement preparedStatement=null;

ResultSet result=null;

String password=null;

try{

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1,username);


result=preparedStatement.executeQuery();//可执行的 查询

if(result.next())

password=result.getString("password");


}catch(SQLException e){

e.printStackTrace();

}finally

{

close(preparedStatement);

close(result);

close(connection);

}

System.out.println("找到的数据库密码为:"+password);

return password;

}

public void close (Connection con)

{

try{

if(con!=null)

{

con.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public void close (PreparedStatement preparedStatement)

{

try{

if(preparedStatement!=null)

{

preparedStatement.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public void close(ResultSet resultSet)

{

try{

if(resultSet!=null)

{

resultSet.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

}

㈢ 用java做好的登陆界面,当登陆成功后跳转到下个页面的代码是什么

用java做好的登陆界面,当登陆成功后跳转到下个页面的代码如下:
如果登陆验证是在jsp中,那么跳转可以写成
1.response.sendRedirct("跳转到页面");
2.<jsp:forward page="跳转页面"/>
3.response.setHeader("Location","");
如果是登陆验证是在servlet中,那么中转可以写成
1.response.sendRedirect("/a.jsp");
2.RequestDispatcher dispatcher = request.getRequestDispatcher("/a.jsp");
dispatcher .forward(request, response);
也可以使用js代码实现:
<script>
function validate(){
window.location.href="/index.jsp";
}
</script>

阅读全文

与注册登录跳转主页源码相关的资料

热点内容
硬盘dos外部命令 浏览:792
做算法还是开发 浏览:872
按键精灵自定义图层命令 浏览:351
魅蓝3手机音视频文件夹 浏览:943
安卓手机制表怎么换行 浏览:215
墙柱搭接箍筋怎么加密 浏览:456
怎么加密不让人打开 浏览:336
2g3g算法 浏览:206
python可以在net开发 浏览:934
编程里的hr啥意思 浏览:411
上海php兼职 浏览:728
顺丰app如何验证学生 浏览:380
服务器mac地址过滤器 浏览:942
程序员一年内被开除 浏览:456
福建文档课件加密企业 浏览:790
appstore美国的界面怎么看呀 浏览:533
hlt单片机 浏览:325
CA的命令 浏览:685
安卓怎么传王者应用给苹果 浏览:923
aws云服务器自建 浏览:840