導航:首頁 > 源碼編譯 > 注冊登錄跳轉主頁源碼

注冊登錄跳轉主頁源碼

發布時間: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>

閱讀全文

與注冊登錄跳轉主頁源碼相關的資料

熱點內容
如何判斷基本命令 瀏覽:972
pdf批量刪除 瀏覽:943
廣播android靜態動態區別 瀏覽:390
centos7設置為命令行啟動 瀏覽:570
程序員資質資格證 瀏覽:217
常見編碼加密 瀏覽:236
阿狸免費雲伺服器 瀏覽:764
快速配置伺服器bmc地址 瀏覽:968
機械手臂編程自動化 瀏覽:501
怎麼看銀行app的銀行卡號 瀏覽:84
pdf文件改ppt 瀏覽:196
ecs對比雲伺服器 瀏覽:852
必剪app怎麼沒有美顏 瀏覽:176
唯庫的視頻怎麼下載app 瀏覽:465
面度雲伺服器 瀏覽:353
加密狗華為 瀏覽:6
光遇安卓版和ios怎麼一起玩 瀏覽:52
飛機空氣動力學pdf 瀏覽:25
AndroidBinder設計與 瀏覽:278
jasperjava 瀏覽:634