Advertisement
Zajkiss

reg

Dec 4th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.53 KB | None | 0 0
  1. <?php
  2. include('config.php');
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6.     <head>
  7.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8.         <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
  9.         <title>Sign up</title>
  10.     </head>
  11.     <body>
  12.         <div class="header">
  13.             <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Members Area" /></a>
  14.         </div>
  15. <?php
  16. //We check if the form has been sent
  17. if(isset($_POST['username'], $_POST['password'], $_POST['passverif'], $_POST['email'], $_POST['vardas'],$_POST['pavarde'],$_POST['amzius']) and $_POST['username']!='')
  18. {
  19.     //We remove slashes depending on the configuration
  20.     if(get_magic_quotes_gpc())
  21.     {
  22.         $_POST['username'] = stripslashes($_POST['username']);
  23.         $_POST['password'] = stripslashes($_POST['password']);
  24.         $_POST['passverif'] = stripslashes($_POST['passverif']);
  25.         $_POST['email'] = stripslashes($_POST['email']);
  26.         $_POST['vardas'] = stripslashes($_POST['vardas']);
  27.             $_POST['pavarde'] = stripslashes($_POST['pavarde']);
  28.                   $_POST['metai'] = (int)$_POST['metai'];
  29.                    $_POST['menuo'] = (int)$_POST['menuo'];
  30.                     $_POST['diena'] = (int)$_POST['diena'];
  31.                 $birthdate = new DateTime( $_POST['diena']."-".$_POST['menuo']."-".$_POST['diena']);
  32. $today     = new DateTime();
  33. $interval  = $today->diff($birthdate);
  34. echo $interval->format('%y years');
  35.  
  36.                $amzius= $interval->format('%y years');
  37.                 $cenzas='18'  ;
  38.                
  39.        
  40.     }
  41.         if($cenzas<18) {
  42.     //We check if the two passwords are identical
  43.     if($_POST['password']==$_POST['passverif'])
  44.     {
  45.         //We check if the password has 6 or more characters
  46.         if(strlen($_POST['password'])>=6)
  47.         {
  48.             //We check if the email form is valid
  49.             if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email']))
  50.             {
  51.                 //We protect the variables
  52.                 $username = mysql_real_escape_string($_POST['username']);
  53.                 $password = mysql_real_escape_string($_POST['password']);
  54.                 $email = mysql_real_escape_string($_POST['email']);
  55.                 $vardas = mysql_real_escape_string($_POST['vardas']);
  56.                 $pavarde = mysql_real_escape_string($_POST['pavarde']);
  57.                 $amzius = mysql_real_escape_string($_POST['amzius']);
  58.                  $_POST['metai'] = (int)$_POST['metai'];
  59.                    $_POST['menuo'] = (int)$_POST['menuo'];
  60.                     $_POST['diena'] = (int)$_POST['diena'];
  61.                  $birthdate = new DateTime( $_POST['diena']."-".$_POST['menuo']."-".$_POST['diena']);
  62. $today     = new DateTime();
  63. $interval  = $today->diff($birthdate);
  64. echo $interval->format('%y years');
  65.                 //We check if there is no other user using the same username
  66.                 $dn = mysql_num_rows(mysql_query('select id from users where username="'.$username.'"'));
  67.                 if($dn==0)
  68.                 {
  69.                     //We count the number of users to give an ID to this one
  70.                     $dn2 = mysql_num_rows(mysql_query('select id from users'));
  71.                     $id = $dn2+1;
  72.                     //We save the informations to the databse
  73.                     $rank = 0;
  74.                     $amzius= $interval->format('%y years');
  75.                     if(mysql_query('insert into users(id, username, password, email,name,last_name,age,rank, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "'.$vardas.'", "'.$pavarde.'", "'.$amzius.'","'.$rank.'", "'.time().'")'))
  76.                     {
  77.                         //We dont display the form
  78.                         $form = false;
  79. ?>
  80. <div class="message">Jūs sėkmingai užsiregistravote. Darbar galite prisijungti<br />
  81. <a href="connexion.php">Prisijungti</a></div>
  82. <?php
  83.                     }
  84.                     else
  85.                     {
  86.                         //Otherwise, we say that an error occured
  87.                         $form = true;
  88.                         $message = 'Registruojantis įvyko klaida.';
  89.                     }
  90.                 }
  91.                 else
  92.                 {
  93.                     //Otherwise, we say the username is not available
  94.                     $form = true;
  95.                     $message = 'Slapyvardis kurį įvedėte yra užimtas. Prašome pasirinkti kitą.';
  96.                 }
  97.             }
  98.             else
  99.             {
  100.                 //Otherwise, we say the email is not valid
  101.                 $form = true;
  102.                 $message = 'El.paštas įvestas neteisingai.';
  103.             }
  104.         }
  105.         else
  106.         {
  107.             //Otherwise, we say the password is too short
  108.             $form = true;
  109.             $message = 'Slaptažodis turi susidėti iš mažiausiai 6 simbolių.';
  110.         }
  111.        
  112.     }
  113.     else
  114.     {
  115.         //Otherwise, we say the passwords are not identical
  116.         $form = true;
  117.         $message = 'Slaptažodžiai nesutampa.';
  118.     }
  119. }
  120. else
  121.     {
  122.         //Otherwise, we say the passwords are not identical
  123.         $form = true;
  124.         $message = 'Tau nėra 18metų';
  125.     }
  126.  
  127. }
  128.  
  129. else
  130. {
  131.     $form = true;
  132. }
  133. if($form)
  134. {
  135.     //We display a message if necessary
  136.     if(isset($message))
  137.     {
  138.         echo '<div class="message">'.$message.'</div>';
  139.     }
  140.     //We display the form
  141. ?>
  142. <div class="content1">
  143.     <form action="sign_up.php" method="post">
  144.        Prašome užpildyti apačioje pateikta registracijos formą:<br />
  145.         <div class="center">
  146.             <label for="username">Slapyvardis</label><input type="text" name="username" value="<?php if(isset($_POST['username'])){echo htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
  147.             <label for="password">Slaptažodis<span class="small">(6 simboliai min.)</span></label><input type="password" name="password" /><br />
  148.             <label for="passverif">Slaptažodis<span class="small">(pakartotinai)</span></label><input type="password" name="passverif" /><br />
  149.             <label for="email">El.paštas</label><input type="text" name="email" value="<?php if(isset($_POST['email'])){echo htmlentities($_POST['email'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
  150.             <label for="avatar">Vardas<span class="small"></span></label><input type="text" name="vardas" value="<?php if(isset($_POST['vardas'])){echo htmlentities($_POST['vardas'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
  151.             <label for="avatar">Pavardė<span class="small"></span></label><input type="text" name="pavarde" value="<?php if(isset($_POST['pavarde'])){echo htmlentities($_POST['pavarde'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
  152.             <label for="avatar">Amžius<span class="small"></span></label><input type="number" name="amzius" value="<?php if(isset($_POST['amzius'])){echo htmlentities($_POST['amzius'], ENT_QUOTES, 'UTF-8');} ?>" /><br />
  153.            
  154.            
  155. Gimimo data:
  156.  
  157. <select name="year" id="year" value="<?php if(isset($_POST['metai'])){echo htmlentities($_POST['metai'], ENT_QUOTES, 'UTF-8');} ?>">
  158. <option value="na">Metai</option>
  159. </select>
  160. <select name="month" onChange="changeDate(this.options[selectedIndex].value);" value="<?php if(isset($_POST['menuo'])){echo htmlentities($_POST['menuo'], ENT_QUOTES, 'UTF-8');} ?>">
  161. <option value="na">Mėnuo</option>
  162. <option value="1">Sausis</option>
  163. <option value="2">Vasaris</option>
  164. <option value="3">Kovas</option>
  165. <option value="4">Balandis</option>
  166. <option value="5">Gegužė</option>
  167. <option value="6">Birželis</option>
  168. <option value="7">Liepa</option>
  169. <option value="8">Rugpjūtis</option>
  170. <option value="9">Rugsėjis</option>
  171. <option value="10">Spalis</option>
  172. <option value="11">Lapkritis</option>
  173. <option value="12">Gruodis</option>
  174. </select>
  175. <select name="day" id="day" value="<?php if(isset($_POST['diena'])){echo htmlentities($_POST['diena'], ENT_QUOTES, 'UTF-8');} ?>">
  176. <option value="na">Diena</option>
  177. </select>
  178. <script language="JavaScript" type="text/javascript">
  179. function changeDate(i){
  180. var e = document.getElementById('day');
  181. while(e.length>0)
  182. e.remove(e.length-1);
  183. var j=-1;
  184. if(i=="na")
  185. k=0;
  186. else if(i==2)
  187. k=28;
  188. else if(i==4||i==6||i==9||i==11)
  189. k=30;
  190. else
  191. k=31;
  192. while(j++<k){
  193. var s=document.createElement('option');
  194. var e=document.getElementById('day');
  195. if(j==0){
  196. s.text="Day";
  197. s.value="na";
  198. try{
  199. e.add(s,null);}
  200. catch(ex){
  201. e.add(s);}}
  202. else{
  203. s.text=j;
  204. s.value=j;
  205. try{
  206. e.add(s,null);}
  207. catch(ex){
  208. e.add(s);}}}}
  209. y = 1993;
  210. while (y-->1940){
  211. var s = document.createElement('option');
  212. var e = document.getElementById('year');
  213. s.text=y;
  214. s.value=y;
  215. try{
  216. e.add(s,null);}
  217. catch(ex){
  218. e.add(s);}}
  219. </script>
  220.  
  221.            
  222.            
  223.            
  224.            
  225.            
  226.             <input type="submit" value="Sign up" />
  227.         </div>
  228.     </form>
  229. </div>
  230. <?php
  231. }
  232. ?>
  233.         <div class="foot"><a href="<?php echo $url_home; ?>">Go Home</a> - <a href="http://www.webestools.com/">Webestools</a></div>
  234.     </body>
  235. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement