📄 changedateinsert.java
字号:
/*
*
*用户更改个人信息后,将更该过的信息写入数据库
*/
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*
* @ChangeDateInsert
* @author Zhu Jian Min
* 2000.7.25
*/
public class ChangeDateInsert extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
HtmlOut htmlOut = new HtmlOut (response);
// 得到用户注册式输入的所有信息
Enumeration e;
String name,pass,pass2,firstname,question,answer,email,gender,birthYear,birthMonth,birthDay;
String education,jobfunction,state,phone,mobile,BP,city,zip,id_type,passid,address;
int ID,awoke;
awoke=0;
e = request.getParameterNames();
name = CommonMethods.GetUserName(request);
pass = request.getParameter("password");
pass=CommonMethods.DealWithGBCodeOfRequest(pass);
firstname=request.getParameter("firstname");
firstname=CommonMethods.DealWithGBCodeOfRequest(firstname);
question=request.getParameter("question");
question=CommonMethods.DealWithGBCodeOfRequest(question);
answer=request.getParameter("answer");
answer=CommonMethods.DealWithGBCodeOfRequest(answer);
email=request.getParameter("email");
email=CommonMethods.DealWithGBCodeOfRequest(email);
gender=request.getParameter("gender");
gender=CommonMethods.DealWithGBCodeOfRequest(gender);
birthYear=request.getParameter("birthYear");
birthYear=CommonMethods.DealWithGBCodeOfRequest(birthYear);
birthMonth=request.getParameter("birthMonth");
birthMonth=CommonMethods.DealWithGBCodeOfRequest(birthMonth);
birthDay=request.getParameter("birthDay");
birthDay=CommonMethods.DealWithGBCodeOfRequest(birthDay);
education=request.getParameter("education");
education=CommonMethods.DealWithGBCodeOfRequest(education);
jobfunction=request.getParameter("jobfunction");
jobfunction=CommonMethods.DealWithGBCodeOfRequest(jobfunction);
state=request.getParameter("state");
state=CommonMethods.DealWithGBCodeOfRequest(state);
phone=request.getParameter("phone");
phone=CommonMethods.DealWithGBCodeOfRequest(phone);
mobile=request.getParameter("mobile");
mobile=CommonMethods.DealWithGBCodeOfRequest(mobile);
BP=request.getParameter("BP");
BP=CommonMethods.DealWithGBCodeOfRequest(BP);
city=request.getParameter("city");
city=CommonMethods.DealWithGBCodeOfRequest(city);
zip=request.getParameter("zip");
zip=CommonMethods.DealWithGBCodeOfRequest(zip);
id_type=request.getParameter("id_type");
id_type=CommonMethods.DealWithGBCodeOfRequest(id_type);
passid=request.getParameter("city");
passid=CommonMethods.DealWithGBCodeOfRequest(passid);
address=request.getParameter("address");
address=CommonMethods.DealWithGBCodeOfRequest(address);
if(request.getParameterValues("single")!=null){
int nLength=request.getParameterValues("single").length;//取得提醒方式
String[] dArray=new String[nLength];
dArray=request.getParameterValues("single");
for(int i=0;i<nLength;i++) {
awoke=awoke+Integer.valueOf(dArray[i]).intValue();
}
}
String k=String.valueOf(awoke);
//建立person实例
Person Person = new Person();
//将数据传到person实例中
//Person.setName(name);
Person.setPassword(pass);
Person.setFirstname(firstname);
Person.setQuestion(question);
Person.setAnswer(answer);
Person.setEmail(email);
Person.setGender(gender);
Person.setBirthYear(birthYear);
Person.setBirthMonth(birthMonth);
Person.setBirthDay(birthDay);
Person.setEducation(education);
Person.setJobfunction(jobfunction);
Person.setState(state);
Person.setPhone(phone);
Person.setCity(city);
Person.setZip(zip);
Person.setPassid(passid);
Person.setID_type(id_type);
Person.setAddress(address);
if(name!=null){
name = name.trim ();
}
if(!Person.checkUsername(name))
{
htmlOut.setErrorID(htmlOut.USER_HAS_BEEN_EXISTED ,"changeuserinfo","此用户已经存在",
"Login");
htmlOut.outHtml();
return;
}
else
{
//设置sql 语句
Person.GetUserID(name);
ID=Person.getID();
String Query="update person set username='"+ name + "',password='" + pass + "',firstname='" +
firstname + "',question= '"+question+"',answer='"+answer+"',email='"+
email+"',gender='"+gender+"',birthYear='"+birthYear+"',birthMonth='"+
birthMonth+"',birthDay='"+ birthDay+"',education='"+education+"',jobfunction='"+
jobfunction+"',state='"+state+"',phone='"+phone+"',mobile='"+mobile+"',BP='"+BP+"',city='"+
city+"',zip='"+zip+"',id_type='"+id_type+"',passid='"+passid+"',address='"+address+"',ID='"+ID+"',awoke='"+awoke+"' where username='"+name+"'";
//将数据插入到数据库中
if(!Person.insertUserdata(Query))
{
}
else
{
htmlOut.setErrorID(htmlOut.USER_HAS_SUCCEEDED_TO_CHANGE_HIS_INFOMATION,
"","您已经成功的更改了你的个人信息","Login");
//要在此处设一个cookie
htmlOut.addCookie ("username",name);
htmlOut.addCookie ("password",pass);
htmlOut.outHtml();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -