|
 |
|
ผมมีปัญหาการทำงานของฟอร์มสองตัวน่ะครับ มันดันซ้อนทับกันน่ะครับ ภาษา JSP ครับ ช่วยด้วยครับ |
|
 |
|
|
 |
 |
|
ใช้ Session ของ JSP น่ะครับ เช่น
Code (Java)
<%
String strUser = String.valueOf(session.getAttribute("sUser"));
if(strUser != null && !strUser.isEmpty())
{
%>
//XYZ
<%
}
%>
|
 |
 |
 |
 |
Date :
2015-02-22 20:50:54 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือผมไม่รู้ว่าที่ผมอธิบายไปพี่จะเข้าใจหรือป่าว แต่ที่ผมต้องการคือ เมื่อเราล๊อกอิน โปรไฟล์จะไปอยู่ในตำแหน่งของ ล๊อกอินทันทีนะครับ โดยที่มันไม่ได้เปลี่ยนไปหน้าอื่น
|
 |
 |
 |
 |
Date :
2015-02-22 21:27:54 |
By :
Ti-Sa-K |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
และพบปัญหาอีกหนึ่งอย่างครับ คือไม่สามารถเปลี่ยนหน้าไปตามที่ต้องการได้

Code (Java)
<%
if(request.getParameter("Action") != null)
{
Connection connect = null;
Statement s = null;
try {
Class.forName("com.mysql.jdbc.Driver");
connect = DriverManager.getConnection("jdbc:mysql://localhost/hd" ,"root","25032535");
String username = request.getParameter("user");
String password = request.getParameter("password");
s = connect.createStatement();
String sql = "SELECT * FROM members WHERE " +
" username = '" + username + "' AND " +
" password = '" + password + "' ";
ResultSet rec = s.executeQuery(sql);
if(!rec.next())
{
out.println("Username or Password ไม่ถูกต้อง");
} else {
rec.first();
session.setAttribute("sid",rec.getString("id"));
request.getRequestDispatcher("/index2.jsp").forward(request, response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
out.println(e.getMessage());
e.printStackTrace();
}
try {
if(s!=null){
s.close();
connect.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
out.println(e.getMessage());
e.printStackTrace();
}
}
%>
<div class="login">
<form action="index.jsp?Action=#login" method="post">
<input type="text" placeholder="username" name="user"><br>
<input type="password" placeholder="password" name="password"><br>
<input type="submit" typea="button" name="Submit" value="Login">
</form>
</div>
</div>
|
 |
 |
 |
 |
Date :
2015-02-23 15:19:18 |
By :
illmndraft |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|