guestBook.aspx.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;

public partial class _Default : System.Web.UI.Page 
{
	
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.clear.CausesValidation = false;
            this.submit.CausesValidation = false;
            System.Random rd = new Random();
            string rand = Convert.ToString(rd.Next(1000, 9999));
            this.validate.Text = rand;
        }
    }
    protected void submit_Click(object sender, EventArgs e)
    {
        if (this.txtValidate.Text == this.validate.Text)
        {
        }
        else
        {
            this.RequiredFieldValidator2.IsValid = false;
        }
        if (this.txtName.Text.Equals(""))
        {
            this.RequiredFieldValidator1.IsValid = false;
        }
        if (this.txtContent.Text.Equals(""))
        {
            this.RequiredFieldValidator3.IsValid = false;
        }
        if (this.RequiredFieldValidator1.IsValid == true && this.RequiredFieldValidator2.IsValid == true && this.RequiredFieldValidator3.IsValid == true)
        {
            OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" +
System.Web.HttpContext.Current.Server.MapPath("~/App_Data/db.mdb"));
            string strIP = Request.ServerVariables["REMOTE_ADDR"].ToString();
            string strSQL = "insert into guestBook(gname,gcontent,gIP) values('" + Server.HtmlDecode(this.txtName.Text) + "','" + Server.HtmlDecode(this.txtContent.Text) + "','" + strIP + "')";
            OleDbCommand cmd = new OleDbCommand(strSQL, conn);
            cmd.Connection.Open();
            if (cmd.ExecuteNonQuery() > 0)
            {
                Response.Redirect("successful.htm");
            }
            conn.Close();
        }


    }
    protected void clear_Click(object sender, EventArgs e)
后面还有 6 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。