日期:2014-05-18  浏览次数:20635 次

谁给我改下这代码啊???
<%@   include   file= "conn.jsp "%>
这是连接数据库文件
我要的功能就是
当输入要删除的帐号后,点击确定才删除帐号,并显示删除成功,
最好还能加个当没有这个帐号的时候,显示没有此帐号。这里面的电话不用管;
<h1> 删除移动通信用户信息 </h1>
<form   action= "delete.jsp "   method= "post "   name= "form1 ">
<center>
<input   type= "radio "   name= "radio "   value= "1 "   /> 帐号: <input   type= "text "   name= "user "   /> <br   />
<input   type= "radio "   name= "radio "   value= "2 "   /> 电话: <input   type= "text "   name= "telephone "   /> <br   /> <br   />
<input   type= "submit "   name= "submit "   value= "确定 "   onclick= "check() "   />
</center>
</form>
</div>
<%  
            String   user=request.getParameter( "user ");
            String   telephone=request.getParameter( "telephone ");
%>
<%@   include   file= "conn.jsp "%>

<script   language= "javascript ">
function   check(){
if   (document.form1.radio.value==1){
<%   String   sql= "delete   from   user_admin   where   user= ' "+user+ " ' ";   %>
}
else{
<%     sql= "delete   from   user_admin   where   telephone= ' "+telephone+ " ' ";   %>
}
}
</script>

<%
         
    statement.execute(sql);
 
statement.close()   ;
connection.close();

%>

<%
out.print( " <script> alert( '删除成功 '); </script> ");

%>

------解决方案--------------------
<%@ include file= "conn.jsp "%>
<%
String user=request.getParameter( "user ");
String telephone=request.getParameter( "telephone ");
String opr=request.getParameter( "opr ");
if(opr.equalsIgnoreCase( "del "))
{
String sql= " ";
if(user==null || user.equalsIgnoreCase( " "))
{
sql= "delete from user_admin where user= ' "+user+ " ' ";
}
if(telephone==null || user.equalsIgnoreCase( " "))
{
sql= "delete from user_admin where telephone= ' "+telephone+ " ' ";
}
if(statement.execute(sql))
{
out.print( " <script> alert( '删除成功 '); </script> ");
}
else
{
out.print( " <script> alert( '没有此用户 '); </script> ");
}
statement.close() ;
connection.close();
}
%>
<script language= "javascript ">
function check(){
var result = confirm( "您确定要删除该信息吗? ");
if (result == false) {
return;
}
form1.submit();
}
</script>
<h1> 删除移动通信用户信息 </h1