Guest User

Untitled

a guest
Jan 5th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.58 KB | None | 0 0
  1. // Here's the PHP portion:
  2.  
  3. <?php
  4.  
  5. include('User.datatype.php');
  6.  
  7. class NewUser {
  8.  
  9.     function inquireSubmit() {
  10.         if(isset($_POST['register'])) {
  11.             $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
  12.             $password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
  13.         }
  14.         else {
  15.             exit;
  16.         }
  17.     }
  18.  
  19.     function createUser($username, $password) {
  20.         if ($username == '' or $password == '')
  21.         {
  22.             $msg = 'Please enter the required information.';
  23.             header('Location: index.php?error=$msg');
  24.         }
  25.    
  26.         else {
  27.             $user = new User;
  28.             $user->username = $username;
  29.             $user->password = $password;
  30.             $user->profile = $profile;
  31.         }
  32.     }
  33. }
  34.  
  35. class UserManager {
  36.  
  37.     function storeData($newUser) {
  38.         $database = mysql_connect("localhost", "root", "");
  39.         mysql_select_db("test") or die(mysql_error('error'));
  40.  
  41.         $username_e = mysql_real_escape_string($username);
  42.         $password_e = mysql_real_escape_string($password);
  43.  
  44.         $query = "INSERT INTO users (username, password) VALUES ($username_e, $password_e)";
  45.         $result = mysql_query($query);
  46.     }
  47. }
  48.  
  49.  
  50. ?>
  51.  
  52.  
  53. // HTML
  54.  
  55.             <form method="POST" id="register" action="register.php">
  56.                 <table cellpadding="2" cellspacing="2" border="0">
  57.                     <tr valign="top">
  58.                         <td>
  59.                             Username: <input name="username" type="text" id="username" />
  60.                         </td>
  61.                     </tr>
  62.                     <tr valign="top">
  63.                         <td>
  64.                             Password: <input name="password" type="password" id="password" />
  65.                         </td>
  66.                         <td>
  67.                             <button type="submit" name="register">Register</button>
  68.                         </td>
  69.                     </tr>
  70.                 </table>
  71.             </form>
Add Comment
Please, Sign In to add comment