Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo '<link href="style.css" rel="stylesheet" type="text/css"/>
- <div id="content" align="center"><h1>Register</h1>';
- $hostname = "localhost";
- $username = "st2014";
- $dbname = "st2014";
- $password = "progress!";
- if (isset($_REQUEST['attempt'])) {
- $regusername = $_POST['username'];
- $regpassword = sha1($_POST['password']);
- $repeatpass = sha1($_POST['repeatpassword']);
- $realname = $_POST['realname'];
- $con=mysqli_connect($hostname,$username,$password,$dbname);
- // Check connection
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- $result = mysqli_query($con,"SELECT * FROM t123891v1_users
- WHERE username='$regusername'");
- $rowname = "";
- while ($row = mysqli_fetch_array($result)) {
- $rowname = $row['username'];
- }
- if($rowname == $regusername) {
- echo "User Already in Exists<br/>";
- } else {
- if($regpassword == $repeatpass) {
- mysql_connect($hostname, $username, $password) OR DIE ("Unable to
- connect to database! Please try again later.");
- mysql_select_db($dbname);
- //Fetching from your database table.
- $query = "INSERT INTO `t123891v1_users` (`username`, `fullname` ,`password`) VALUES ('$regusername', '$realname', '$regpassword')";
- $result = mysql_query($query);
- echo "User Created!";
- echo '<META HTTP-EQUIV="Refresh" Content="1; URL=index.php">';
- exit();
- } else {
- echo '<br>Passwords didn\'t match, try again!';
- }
- }
- } else {
- echo 'Täitke järgnevad väljad!<br>';
- }
- ?>
- <html>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <form action='register.php?attempt' method="POST">
- <table>
- <tr>
- <td>
- Your username:
- </td>
- <td>
- <input type='text' name='username'/>
- </td>
- </tr>
- <tr>
- <td>
- Your real name:
- </td>
- <td>
- <input type='text' name='realname'/>
- </td>
- </tr>
- <tr>
- <td>
- Your password:
- </td>
- <td>
- <input type='password' name='password'/>
- </td>
- </tr>
- <tr>
- <td>
- Repeat your password:
- </td>
- <td>
- <input type='password' name='repeatpassword'/>
- </td>
- </tr>
- <tr>
- <td>
- Your e-mail:
- </td>
- <td>
- <input type='text' name='email'/>
- </td>
- </tr>
- </table>
- <br>
- <input type='submit' name='submit' value='Register' />
- </form>
- </div>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement