Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- /**
- * Process.php
- */
- include("database.php");
- /** process form */
- /** really shouldnt use posts but u can always sanitize them */
- $subuser = $_POST["username"];
- $subfirst = $_POST["firstname"];
- $subsurname = $_POST["surname"];
- $subpassword = $_POST["password"];
- function usernameTaken($username){
- $q = "SELECT username FROM ".TBL_USERS." WHERE username = '$username'";
- $result = mysql_query($q);
- return (mysql_num_rows($result) > 0);
- }
- /* check username is taken */
- /* username is not in use so we add it to database */
- if (usernameTaken($subuser) == 0 ) {
- $q = mysql_query ("INSERT INTO information (username, firstname, surname, password) VALUES ('$subuser', '$subfirst', '$subsurname', '$subpassword')"); echo mysql_error();
- $success = 1;
- if ($success == 1) { echo "User ".$subuser." Added"; }
- }
- /* username is in use so we tell user and re-display form */
- else if (usernameTaken($subuser) > 0 ) {
- echo "User ".$subuser." already exists, choose another username";
- header('Refresh:3; URL= informationform.php');
- }
- ?>
- <a href="display_users.php">Show Users</a><br / >
- <a href="informationform.php">Add a new user</a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement