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"];
- /* check username is taken */
- /* Username error checking */
- $field = "username";
- if(!$subuser || strlen($subuser = trim($subuser)) == 0){
- // $form->setError($field, "* Username not entered");
- }
- else{
- /* Spruce up username, check length */
- $subuser = stripslashes($subuser);
- if(strlen($subuser) < 4){
- // $form->setError($field, "* Username below 4 characters");
- }
- else if(strlen($subuser) > 30){
- // $form->setError($field, "* Username above 30 characters");
- }
- /* Check if username is not alphanumeric */
- else if(!eregi("^([0-9a-z])+$", $subuser)){
- // $form->setError($field, "* Username not alphanumeric");
- }
- /* Check if username is already in use
- else if(usernameTaken($subuser)){
- $form->setError($field, "* Username already in use");
- } */
- }
- $num_errors = 0;
- /* Errors exist, have user correct them */
- if($num_errors > 0){
- return 1; //Errors with form
- }
- /* No errors, add the new account to the database*/
- else{
- $q = mysql_query ("INSERT INTO users (username, firstname, surname, password) VALUES ('$subuser', '$subfirst', '$subsurname', '$subpassword')"); echo mysql_error();
- $success = 1;
- if ($success == 1) { echo "User Added"; }
- else echo "Error";
- // re direct to form.php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement