Advertisement
Guest User

עומרי

a guest
May 8th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.97 KB | None | 0 0
  1. <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" %>
  2. <%@ Import Namespace="System.Data.SqlClient" %>
  3. <script runat="server">
  4. string note = "";
  5. bool IsExists(string name)
  6. {
  7.  
  8. bool flag = false;
  9. string connString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True";
  10. SqlConnection conn = new SqlConnection(connString);
  11. string cmdString = string.Format("SELECT * FROM myTable WHERE (username = N'{0}')", name);
  12. SqlCommand cmd = new SqlCommand(cmdString, conn);
  13. conn.Open();
  14. SqlDataReader dr = cmd.ExecuteReader();
  15. if (dr.HasRows)
  16. flag = true;
  17. conn.Close();
  18. return flag;
  19. }
  20. protected void Page_Load(object sender, EventArgs e)
  21. {
  22. if (Request.Form["sub"] != null)
  23. {
  24. string userName = Request.Form["txtUser"];
  25. if (IsExists(userName))
  26. {
  27. note = "שם משתמש זה כבר תפוס ! אנא הכנס שם משתמש אחר";
  28. }
  29. else
  30. {
  31. string user = Request.Form["username"].ToString();
  32. string pass = Request.Form["password"].ToString();
  33. int day = int.Parse(Request.Form["ofTheMonth"].ToString());
  34. int month = int.Parse(Request.Form["ofTheYear"].ToString());
  35. int year = int.Parse(Request.Form["years"].ToString());
  36. string email = Request.Form["email"].ToString();
  37. string team = Request.Form["favorite"].ToString();
  38. string city = Request.Form["city"].ToString();
  39. string conStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True";
  40. 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);
  41. SqlConnection conObject = new SqlConnection(conStr);
  42. conObject.Open();
  43. SqlCommand cmdObject = new SqlCommand(cmdStr, conObject);
  44. cmdObject.ExecuteNonQuery();
  45. conObject.Close();
  46. }
  47. }
  48. }
  49.  
  50. </script>
  51.  
  52.  
  53. <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
  54. <script type="text/javascript">
  55. function userCheck() {
  56. if (document.getElementById("txtUser").value == "") {
  57. document.getElementById("user").innerHTML = "הכנס שם משתמש";
  58. return false
  59. }
  60. return true
  61. }
  62. function passCheck() {
  63. if (document.getElementById("txtPass").value == "") {
  64. document.getElementById("pass").innerHTML = "הכנס סיסמא";
  65. return false
  66. }
  67. return true
  68. }
  69. function doublePassCheck() {
  70. if (document.getElementById("txtPassConfirm").value == "") {
  71. document.getElementById("truePass").innerHTML = "חייב לאמת סיסמא";
  72. return false
  73. }
  74. return true
  75. }
  76. function daySelectCheck() {
  77. if (document.getElementById("dayCheck").selected == true) {
  78. document.getElementById("check").innerHTML = " בחר יום ";
  79. return false
  80. }
  81. return true
  82. }
  83. function monthSelectCheck() {
  84. if (document.getElementById("monthCheck").selected == true) {
  85. document.getElementById("check").innerHTML = " בחר חודש ";
  86. return false
  87. }
  88. return true
  89. }
  90. function email() {
  91. var emailCheck = "אימייל לא תקין / לא רשום";
  92. var check = document.getElementById("txtMAil").value;
  93. for (var i = 0; i < check.length; i++) {
  94. if (check.charAt(i) == "@" && check.charAt(0) != "@" && check.indexOf("@") == check.lastIndexOf("@") && check.indexOf(".") > check.indexOf("@") && check.charAt((check.length) - 1) != ".") {
  95. emailCheck = "אימייל תקין";
  96. return true;
  97. }
  98. }
  99. document.getElementById("mail").innerHTML = emailCheck;
  100. return false;
  101. }
  102. function yearCheck() {
  103. if (document.getElementById("yearSelect").selected == true) {
  104. document.getElementById("check").innerHTML = "בחר שנה";
  105. return false;
  106. }
  107. return true;
  108. }
  109. function passPassCheck() {
  110. if(document.getElementById("txtPass").value != document.getElementById("txtPassConfirm").value){
  111. document.getElementById("truePass").innerHTML = "הסיסמאות אינם זהות";
  112. return false;
  113. }
  114. return true;
  115. }
  116.  
  117. function citySelect() {
  118. if (document.getElementById("city").selected == true) {
  119. document.getElementById("cityCheck").innerHTML = "בחר עיר";
  120. }
  121. }
  122. function page() {
  123. a = userCheck();
  124. b = passCheck();
  125. c = doublePassCheck();
  126. d = daySelectCheck();
  127. e = monthSelectCheck();
  128. f = email();
  129. g = yearCheck();
  130. h = passPassCheck();
  131. i = citySelect();
  132. if (a == true && b == true && c == true && d == true && e == true && f == true && g == true && h == true && i == true) {
  133. return true;
  134. }
  135. return false;
  136. }
  137. </script>
  138. <form id="form" action="register.aspx" method="post" dir="rtl"><center>
  139. <table width="550">
  140. <tr align="center">
  141. <td colspan="2"><h1>הרשמה</h1><br /><br />
  142.  
  143. </td>
  144. </tr>
  145.  
  146. <tr>
  147. <td>שם משתמש:</td>
  148. <td><input type="text" id="txtUser" name="username"/></td>
  149. <td id="user"></td>
  150. </tr>
  151.  
  152. <tr>
  153. <td>סיסמא:</td>
  154. <td><input type="password" id="txtPass" name="password"/></td>
  155. <td id="pass"></td>
  156. </tr>
  157.  
  158. <tr>
  159. <td>אימות סיסמא:</td>
  160. <td><input type="password" id="txtPassConfirm" /></td>
  161. <td id="truePass"></td>
  162. </tr>
  163.  
  164. <tr>
  165. <td>תאריך לידה:</td>
  166. <td><select id="day" name="ofTheMonth" >
  167. <option id="dayCheck">בחר יום</option>
  168. <option>1</option>
  169. <option>2</option>
  170. <option>3</option>
  171. <option>4</option>
  172. <option>5</option>
  173. <option>6</option>
  174. <option>7</option>
  175. <option>8</option>
  176. <option>9</option>
  177. <option>10</option>
  178. <option>11</option>
  179. <option>12</option>
  180. <option>13</option>
  181. <option>14</option>
  182. <option>15</option>
  183. <option>16</option>
  184. <option>17</option>
  185. <option>18</option>
  186. <option>19</option>
  187. <option>20</option>
  188. <option>21</option>
  189. <option>22</option>
  190. <option>23</option>
  191. <option>24</option>
  192. <option>25</option>
  193. <option>26</option>
  194. <option>27</option>
  195. <option>28</option>
  196. <option>29</option>
  197. <option>30</option>
  198. <option>31</option>
  199. </select>&nbsp;&nbsp;&nbsp;
  200. <select id="month" name="ofTheYear" >
  201. <option id="monthCheck">בחר חודש</option>
  202. <option>ינואר</option>
  203. <option>פברואר</option>
  204. <option>מרץ</option>
  205. <option>אפריל</option>
  206. <option>מאי</option>
  207. <option>יוני</option>
  208. <option>יולי</option>
  209. <option>אוגוסט</option>
  210. <option>ספטמבר</option>
  211. <option>אוקטובר</option>
  212. <option>נובמבר</option>
  213. <option>דצמבר</option>
  214. </select>&nbsp;&nbsp;&nbsp;
  215. <select id="year" name="years" >
  216. <option id="yearSelect">בחר שנה</option>
  217. <option>2016</option>
  218. <option>2015</option>
  219. <option>2014</option>
  220. <option>2013</option>
  221. <option>2012</option>
  222. <option>2011</option>
  223. <option>2010</option>
  224. <option>2009</option>
  225. <option>2008</option>
  226. <option>2007</option>
  227. <option>2006</option>
  228. <option>2005</option>
  229. <option>2004</option>
  230. <option>2003</option>
  231. <option>2002</option>
  232. <option>2001</option>
  233. <option>2000</option>
  234. <option>1999</option>
  235. <option>1998</option>
  236. <option>1997</option>
  237. <option>1996</option>
  238. <option>1995</option>
  239. <option>1994</option>
  240. <option>1993</option>
  241. <option>1992</option>
  242. <option>1991</option>
  243. <option>1990</option>
  244. <option>1989</option>
  245. <option>1988</option>
  246. <option>1987</option>
  247. <option>אחר</option>
  248. </select>
  249. </td>
  250. <td id="check"></td>
  251. </tr>
  252.  
  253. <tr>
  254. <td>אימייל:</td>
  255. <td><input type="text" id="txtMAil" name="email" /></td>
  256. <td id="mail"></td>
  257. </tr>
  258.  
  259. <tr>
  260. <td>קבוצה אהובה</td>
  261. <td><input type="text" id="Team" name="facorite"/></td>
  262. <td id="favTeam"></td>
  263. </tr>
  264.  
  265. <tr>
  266. <td>הערות</td>
  267. <td><textarea name="area" id="area" rows="5" cols="25"></textarea></td>
  268. </tr>
  269.  
  270. <tr>
  271. <td>עיר:</td>
  272. <td><select>
  273. <option id="city" name="city">בחר עיר</option>
  274. <option>תל אביב</option>
  275. <option>חולון</option>
  276. <option>רעננה</option>
  277. <option>חיפה</option>
  278. <option>ראשלצ</option>
  279. <option>ירושלים</option>
  280. <option>אחר</option>
  281. <option>לא גר בארץ</option>
  282. </select></td>
  283. <td id="cityCheck"></td>
  284. </tr>
  285.  
  286. <tr align="center">
  287. <td colspan="2"><input type="submit" id="send" value="שלח" name="sub"/>&nbsp;&nbsp;<input type="reset" id="reset" /></td>
  288. </tr>
  289.  
  290. </table>
  291. </center>
  292. </form>
  293.  
  294. </asp:Content>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement