Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" %>
- <%@ Import Namespace="System.Data.SqlClient" %>
- <script runat="server">
- string note = "";
- bool IsExists(string name)
- {
- bool flag = false;
- string connString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True";
- SqlConnection conn = new SqlConnection(connString);
- string cmdString = string.Format("SELECT * FROM myTable WHERE (username = N'{0}')", name);
- SqlCommand cmd = new SqlCommand(cmdString, conn);
- conn.Open();
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.HasRows)
- flag = true;
- conn.Close();
- return flag;
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if (Request.Form["sub"] != null)
- {
- string userName = Request.Form["txtUser"];
- if (IsExists(userName))
- {
- note = "שם משתמש זה כבר תפוס ! אנא הכנס שם משתמש אחר";
- }
- else
- {
- string user = Request.Form["username"].ToString();
- string pass = Request.Form["password"].ToString();
- int day = int.Parse(Request.Form["ofTheMonth"].ToString());
- int month = int.Parse(Request.Form["ofTheYear"].ToString());
- int year = int.Parse(Request.Form["years"].ToString());
- string email = Request.Form["email"].ToString();
- string team = Request.Form["favorite"].ToString();
- string city = Request.Form["city"].ToString();
- string conStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True";
- string cmdStr = string.Format("INSERT INTO myTable(username, password, bDay,bMonth,bYear, email, favTeam, notes, city) VALUES (N'{0}', N'{1}', N'{2}', N'{3}', N'{4}', N'{5}', N'{6}', N'{7}', N'{8}')", user, pass, day, month, year, email, team, Request.Form["area"].ToString(),city);
- SqlConnection conObject = new SqlConnection(conStr);
- conObject.Open();
- SqlCommand cmdObject = new SqlCommand(cmdStr, conObject);
- cmdObject.ExecuteNonQuery();
- conObject.Close();
- }
- }
- }
- </script>
- <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
- <script type="text/javascript">
- function userCheck() {
- if (document.getElementById("txtUser").value == "") {
- document.getElementById("user").innerHTML = "הכנס שם משתמש";
- return false
- }
- return true
- }
- function passCheck() {
- if (document.getElementById("txtPass").value == "") {
- document.getElementById("pass").innerHTML = "הכנס סיסמא";
- return false
- }
- return true
- }
- function doublePassCheck() {
- if (document.getElementById("txtPassConfirm").value == "") {
- document.getElementById("truePass").innerHTML = "חייב לאמת סיסמא";
- return false
- }
- return true
- }
- function daySelectCheck() {
- if (document.getElementById("dayCheck").selected == true) {
- document.getElementById("check").innerHTML = " בחר יום ";
- return false
- }
- return true
- }
- function monthSelectCheck() {
- if (document.getElementById("monthCheck").selected == true) {
- document.getElementById("check").innerHTML = " בחר חודש ";
- return false
- }
- return true
- }
- function email() {
- var emailCheck = "אימייל לא תקין / לא רשום";
- var check = document.getElementById("txtMAil").value;
- for (var i = 0; i < check.length; i++) {
- if (check.charAt(i) == "@" && check.charAt(0) != "@" && check.indexOf("@") == check.lastIndexOf("@") && check.indexOf(".") > check.indexOf("@") && check.charAt((check.length) - 1) != ".") {
- emailCheck = "אימייל תקין";
- return true;
- }
- }
- document.getElementById("mail").innerHTML = emailCheck;
- return false;
- }
- function yearCheck() {
- if (document.getElementById("yearSelect").selected == true) {
- document.getElementById("check").innerHTML = "בחר שנה";
- return false;
- }
- return true;
- }
- function passPassCheck() {
- if(document.getElementById("txtPass").value != document.getElementById("txtPassConfirm").value){
- document.getElementById("truePass").innerHTML = "הסיסמאות אינם זהות";
- return false;
- }
- return true;
- }
- function citySelect() {
- if (document.getElementById("city").selected == true) {
- document.getElementById("cityCheck").innerHTML = "בחר עיר";
- }
- }
- function page() {
- a = userCheck();
- b = passCheck();
- c = doublePassCheck();
- d = daySelectCheck();
- e = monthSelectCheck();
- f = email();
- g = yearCheck();
- h = passPassCheck();
- i = citySelect();
- if (a == true && b == true && c == true && d == true && e == true && f == true && g == true && h == true && i == true) {
- return true;
- }
- return false;
- }
- </script>
- <form id="form" action="register.aspx" method="post" dir="rtl"><center>
- <table width="550">
- <tr align="center">
- <td colspan="2"><h1>הרשמה</h1><br /><br />
- </td>
- </tr>
- <tr>
- <td>שם משתמש:</td>
- <td><input type="text" id="txtUser" name="username"/></td>
- <td id="user"></td>
- </tr>
- <tr>
- <td>סיסמא:</td>
- <td><input type="password" id="txtPass" name="password"/></td>
- <td id="pass"></td>
- </tr>
- <tr>
- <td>אימות סיסמא:</td>
- <td><input type="password" id="txtPassConfirm" /></td>
- <td id="truePass"></td>
- </tr>
- <tr>
- <td>תאריך לידה:</td>
- <td><select id="day" name="ofTheMonth" >
- <option id="dayCheck">בחר יום</option>
- <option>1</option>
- <option>2</option>
- <option>3</option>
- <option>4</option>
- <option>5</option>
- <option>6</option>
- <option>7</option>
- <option>8</option>
- <option>9</option>
- <option>10</option>
- <option>11</option>
- <option>12</option>
- <option>13</option>
- <option>14</option>
- <option>15</option>
- <option>16</option>
- <option>17</option>
- <option>18</option>
- <option>19</option>
- <option>20</option>
- <option>21</option>
- <option>22</option>
- <option>23</option>
- <option>24</option>
- <option>25</option>
- <option>26</option>
- <option>27</option>
- <option>28</option>
- <option>29</option>
- <option>30</option>
- <option>31</option>
- </select>
- <select id="month" name="ofTheYear" >
- <option id="monthCheck">בחר חודש</option>
- <option>ינואר</option>
- <option>פברואר</option>
- <option>מרץ</option>
- <option>אפריל</option>
- <option>מאי</option>
- <option>יוני</option>
- <option>יולי</option>
- <option>אוגוסט</option>
- <option>ספטמבר</option>
- <option>אוקטובר</option>
- <option>נובמבר</option>
- <option>דצמבר</option>
- </select>
- <select id="year" name="years" >
- <option id="yearSelect">בחר שנה</option>
- <option>2016</option>
- <option>2015</option>
- <option>2014</option>
- <option>2013</option>
- <option>2012</option>
- <option>2011</option>
- <option>2010</option>
- <option>2009</option>
- <option>2008</option>
- <option>2007</option>
- <option>2006</option>
- <option>2005</option>
- <option>2004</option>
- <option>2003</option>
- <option>2002</option>
- <option>2001</option>
- <option>2000</option>
- <option>1999</option>
- <option>1998</option>
- <option>1997</option>
- <option>1996</option>
- <option>1995</option>
- <option>1994</option>
- <option>1993</option>
- <option>1992</option>
- <option>1991</option>
- <option>1990</option>
- <option>1989</option>
- <option>1988</option>
- <option>1987</option>
- <option>אחר</option>
- </select>
- </td>
- <td id="check"></td>
- </tr>
- <tr>
- <td>אימייל:</td>
- <td><input type="text" id="txtMAil" name="email" /></td>
- <td id="mail"></td>
- </tr>
- <tr>
- <td>קבוצה אהובה</td>
- <td><input type="text" id="Team" name="facorite"/></td>
- <td id="favTeam"></td>
- </tr>
- <tr>
- <td>הערות</td>
- <td><textarea name="area" id="area" rows="5" cols="25"></textarea></td>
- </tr>
- <tr>
- <td>עיר:</td>
- <td><select>
- <option id="city" name="city">בחר עיר</option>
- <option>תל אביב</option>
- <option>חולון</option>
- <option>רעננה</option>
- <option>חיפה</option>
- <option>ראשלצ</option>
- <option>ירושלים</option>
- <option>אחר</option>
- <option>לא גר בארץ</option>
- </select></td>
- <td id="cityCheck"></td>
- </tr>
- <tr align="center">
- <td colspan="2"><input type="submit" id="send" value="שלח" name="sub"/> <input type="reset" id="reset" /></td>
- </tr>
- </table>
- </center>
- </form>
- </asp:Content>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement