课程查询系统(较简单)

页面展示:







主要代码:

登录:

<?php
if(isset($_POST['sub'])){  //检测变量是否设置,判断post过来的数据是否被提交过来
$uname=@$_POST['uname'];   //获取用户输入的用户名
$upwd=@$_POST['upwd'];     //获取用户输入的密码
//判断用户输入是否为空
if($uname==""||$upwd==""){
    echo "<script>alert('请输入用户名或密码!');</script>";
}
else{
    session_start();   //开启session
    $_SESSION['uname']=$uname;   //使用session变量传值
    $_SESSION['upwd']=$upwd;     //使用session变量传值
    header("location:login_show.php");  //页面跳转
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <title>河南中医药大学课程查询系统</title>
    <meta charset="utf-8">
    <style type="text/css">
    body{
        cellpadding:0;
        cellspacing:0;
        margin:0;
        pading:0;
        background-color: #CCFFCC;
    }
    #con
    {
        padding :0;
        margin:0;
        width:1364px;
        height:600px;
        background-image:url(./images/beijing.png);
        background-repeat :no-repeat ;
        background-position :center ;
        background-color :#CCFFCC;
    }
    table{
        position:relative;
        top:250px;
        margin:auto;
        width:300px;
    }
    .txt
    {
            width:220px;
        height:30px;
        margin-bottom:10px;
            border:1px solid green;
            text-align :left;
        line-height :30px;
        font-size:18px;
        color :Black ;
    }
    .btn
    {
            width :70px;
        height :30px;
    }
    #btn1{
        margin-left:70px;
        margin-right:20px;
    }
    a{
        margin-left:20px;
        font-size:14px;
        color:green;
        text-decoration: none;
    }
    a:hover{
        color:#CCCCCC;
    }
    </style>
</head>
<body>
    <div id="con">
    <form action="login.php" method="post">
    <table>
    <tr>
    <td>用户名:</td>
    <td><input type="text" name="uname" class="txt"></td>
    </tr>
    <tr>
    <td>密 &nbsp 码:</td>
    <td><input type="text" name="upwd" class="txt"></td>
    </tr>
    <tr>
    <td colspan="2">
        <input type="submit" name="sub" value="登录" class="btn" id="btn1">
        <input type="reset" name="ret" value="重置" class="btn">
        <a href="login_zhuce.php">注册</a>
    </td>
    </tr>
    </table>
    </form>
    </div>
</body>
</html>

注册:

<?php
if(isset($_POST['sub'])){  //检测变量是否设置,判断post过来的数据是否被提交过来
$uname=@$_POST['uname']; //获取用户输入的用户名
$name=@$_POST['name'];
$usex=@$_POST['sex'];
$ubir=@$_POST['ubir'];
$uclass=@$_POST['uclass'];
$upwd=@$_POST['upwd'];   //获取用户输入的密码
//判断用户输入是否为空
if($uname==""||$upwd==""){
    echo "<script>alert('请输入学号或密码!');</script>";
}
else{
    $conn=@mysql_connect('localhost:3307','root','') or die('连接失败');//建立与数据库的连接
    mysql_select_db('kccxxt',$conn) or die('选择数据库失败');  //选择数据库
    mysql_query("SET NAMES utf8");//设置字符集
    $s_sql="select * from user where uid='$uname' and upwd='$upwd'";//sql查询语句
    $s_result=@mysql_query($s_sql) or die('执行查询失败');  //执行SQL语句
    $s_row=@mysql_fetch_array($s_result);//从返回的结果集中获取数据
    //判断数据表中是否有该条数据,即判断该用户是否已被注册
    if($s_row){      
        echo "<script>alert('该用户已存在&#x

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
查询功能代码(包括普通查询和全部查询):protected void Button2_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); DataBS(ds, strsql); GridView1.DataSource = ds.Tables["table"]; GridView1.DataBind(); DropDownList1.SelectedValue = "不限"; DropDownList2.SelectedValue = "不限"; DropDownList3.SelectedValue = "不限"; DropDownList4.SelectedValue = "不限"; DropDownList5.SelectedValue = "不限"; Label8.Text = "查询结果: 共" + ds.Tables[0].Rows.Count + "条记录"; } protected void Button1_Click(object sender, EventArgs e) { string str = ""; string str1 = ""; if (DropDownList1.SelectedItem.Text != "不限") str += " and CourseGrade='" + DropDownList1.SelectedValue + "'"; if (DropDownList2 .SelectedItem .Text !="不限") str +=" and CourseTerm='" + DropDownList2.SelectedValue + "'"; if (DropDownList3.SelectedItem.Text != "不限") str += " and CourseSort='" + DropDownList3.SelectedValue + "'"; if (DropDownList4.SelectedItem.Text != "不限") str += " and SpecialtyDirection='" + DropDownList4.SelectedValue + "'"; if (DropDownList5.SelectedItem.Text != "不限") str += " and CourseTeacher='" + DropDownList5.SelectedValue + "'"; if (str != "") { str1 = str.Substring(5); strsql += " where " + str1; } DataSet ds = new DataSet(); DataBS(ds, strsql); if (ds.Tables[0].Rows.Count != 0) { GridView1.DataSource = ds.Tables["table"]; GridView1.DataBind(); } else { Response.Write("<script language=JavaScript>alert('没有符合条件的记录!');</script>"); GridView1.Visible = true ; } Label8.Text = "查询结果: 共" + ds.Tables[0].Rows.Count + "条记录"; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值