users/Register.aspx.cs

(开头部分) 3KB

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

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnReg_Click(object sender, EventArgs e)
    {
        string sql = "";
        if (Convert.ToBoolean(Session["IsReg"]))
        {
            string InterstedProduct = "";
            for (int i = 0; i < chkInterstedProduct.Items.Count; i++)
                if (chkInterstedProduct.Items[i].Selected)
                    InterstedProduct = InterstedProduct + chkInterstedProduct.Items[i].Text + "";
            if (FileUpload1.HasFile)
            {
                bool fileOK = false;
                String fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
                String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                foreach (string str in allowedExtensions)
                {
                    if (fileExtension == str)
                    {
                        fileOK = true;
                        break;  //强制跳出循环
                    }
                }
                if (fileOK)
                {
                    string path = "~/Photo/";
                    string spath = Server.MapPath(path);
                    string filename = txtName.Text + fileExtension;
                    FileUpload1.PostedFile.SaveAs(spath + filename);
                    sql = "insert into UserInfo(UserName,UserPwd,Address,Phone,Email,PostCode,Education,InterestedProduct,UserPhoto,UserSex) values('" + txtName.Text + "','" + txtPwd.Text + "','" + Address.Text + "','" + txtTel.Text + "','" + txtEmail.Text + "','" + txtCode.Text + "','" + drpDiploma.SelectedValue + "','" + InterstedProduct
                        + "','" + path + filename + "','" + RadioSex.SelectedValue + "')";
                    if (MyClass.ExecuteSql(sql) > 0)
                    {
                        Response.Write("<script>alert('恭喜您,注册成功!');location='Login.aspx'</script>");
                    }
                    else
                    {
                       Response.Write("<script>alert('文件类型不对!')</script>");
                    }
                }
                else
                {
后面还有 18 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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