Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- include 'connect.php'; //connect to mysql database
- include 'start.php'; //opening html for page
- function regdetails() {
- print "Register for an account on Bo-News:<br><br>
- <form action='register.php' method='post'>
- <table>
- <tr>
- <td>Username:</td><td><input type='text' name='username'>
- </tr>
- <tr>
- <td>Password:</td><td><input type='password' name='password'>
- </tr>
- <tr>
- <td>Confirm Password:</td><td><input type='password' name='confirmpassword'>
- </tr>
- <tr>
- <td>Email:</td><td><input type='text' name='email'>
- <tr>
- <td align='right'><input type='submit' value='register'>
- </tr>
- </table>
- </form>";
- }
- //if we've tried to submit some data
- //make sure we've entered everything out properly
- if ($_POST['username'] != "") {
- if ($_POST['password'] == "") { $error[$err] = "No password was entered!"; $err++; }
- if ($_POST['confirmpassword'] == "") { $error[$err] = "You did not confirm your password!"; $err++; }
- if ($_POST['confirmpassword'] != $_POST['password']) { $error[$err] = "Your passwords don't match!"; $err++; }
- if ($_POST['email'] == "") { $error[$err] = "No email was entered!"; $err++; }
- //check if email is a valid address
- if ($err == 0;) {
- mysql_query("INSERT INTO users (username, password, email) VALUES('".$_POST['username']."','".$_POST['password']."','".$_POST['email']."' ) ") or die(mysql_error());
- }
- else {
- print "<table>";
- while ($i < $err) {
- print "<tr><td>". $error[$i] ."</td></tr>";
- $i++;
- }
- print "</table><br><br>";
- regdetails();
- }
- }
- else { regdetails(); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement