SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Question Solved: A function error is driving me crazy...

    Hi everyone.

    I am making some php for a member-registration on a website. The method I'm using is different to what I usually do, mainly because I am making it to be re-used in any websites I make. I have a problem in the validation process. Whenever the below function is called, output after it is called is stopped. Also, output after the line:
    Code PHP:
    $Register_Repeat_Password = $_POST['Register_Repeat_Password'];
    fails. I can't see any problem though. Can anyone see the problem? I have checked other functions which are within this function, and they are all fine.
    PHP Code:
    function Register_User(){
        
    $Error_Count 0;
        
    $Problem_Fields = array();
        
    $Register_Full_Name $_POST['Register_Full_Name'];
        if(!
    step1($Register_Full_Name)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Full_Name'] = "Field left empty";
        }
        
    $Register_Email_Address $_POST['Register_Email_Address'];
        if(!
    step1($Register_Email_Address)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Email_Address'] = "Field left empty";
        }elseif(!
    Check_Email($Register_Email_Address)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Email_Address'] = "Email Address is Incorrect";
        }
        
    $Register_Username $_POST['Register_Username'];
        if(!
    step1($Register_Username)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Username'] = "Field left empty";
        }elseif(!
    Check_Size($Register_Username330)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Username'] = "Username must be between 3 and 30 characters";
        }elseif(!
    Unique_Username($Register_Username)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Username'] = "Username Already Exists";
        }
        
    $Register_Password $_POST['Register_Password'];
        if(!
    step1($Register_Password)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Password'] = "Field left empty";
        }
        
    $Register_Repeat_Password $_POST['Register_Repeat_Password'];
        if(!
    step1($Register_Repeat_Password)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Repeat_Password'] = "Field left empty";
        }elseif(
    md5($Register_Repeat_Password) != md5($Register_Password)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Repeat_Password'] = "Passwords don't match";
        }
        
    $Register_Street_Address $_POST['Register_Street_Address'];     echo "LLLaaammaaa<br />";
        if(!
    step1($Register_Street_Address)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Street_Address'] = "Field left empty";
        }
        
    $Register_Street_Address_2 $_POST['Register_Street_Address_2'];
        if(!
    step1($Register_Street_Address_2)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Street_Address_2'] = "Field left empty";
        }
        
    $Register_Town_City $_POST['Register_Town_City'];
        if(!
    step1($Register_Town_City)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Town_City'] = "Field left empty";
        }
        
    $Register_County $_POST['Register_County'];
        if(!
    step1($Register_County)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_County'] = "Field left empty";
        }
        
    $Register_Post_Code $_POST['Register_Post_Code'];
        if(!
    step1($Register_Post_Code)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Post_Code'] = "Field left empty";
        }
        
    $Register_Delivery_Street_Address $_POST['Register_Delivery_Street_Address'];
        if(!
    step1($Register_Delivery_Street_Address)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Delivery_Street_Address'] = "Field left empty";
        }
        
    $Register_Delivery_Street_Address_2 $_POST['Register_Delivery_Street_Address_2'];
        if(!
    step1($Register_Delivery_Street_Address_2)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Delivery_Street_Address_2'] = "Field left empty";
        }
        
    $Register_Delivery_Town_City $_POST['Register_Delivery_Town_City'];
        if(!
    step1($Register_Delivery_Town_City)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Delivery_Town_City'] = "Field left empty";
        }
        
    $Register_Delivery_County $_POST['Register_Delivery_County'];
        if(!
    step1($Register_Delivery_County)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Delivery_County'] = "Field left empty";
        }
        
    $Register_Delivery_Post_Code $_POST['Register_Delivery_Post_Code'];
        if(!
    step1($Register_Delivery_Post_Code)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Delivery_Post_Code'] = "Field left empty";
        }
        
    $Register_Telephone_Number $_POST['Register_Telephone_Number'];
        if(!
    step1($Register_Telephone_Number)){
            
    $Error_Count++;
            
    $Problem_Fields['Register_Telephone_Number'] = "Field left empty";
        }
        if(
    $Error_Count == 0){
            
    $Insert_User mysql_query("INSERT INTO `users` (`username`, `password`, `Full_Name`, `Email_Address`, `Street_Address`, `Street_Address_2`, `Town_City`, `County`, `Post_Code`, `Delivery_Street_Address`, `Delivery_Street_Address_2`, `Delivery_Town_City`, `Delivery_County`, `Delivery_Post_Code`, `Telephone` ) VALUES ('".$Register_Username."', '".md5($Register_Password)."', '".$Register_Full_Name."', '".$Register_Email_Address."', '".$Register_Street_Address."', '".$Register_Street_Address_2."', '".$Register_Town_City."', '".$Register_County."', '".$Register_Post_Code."', '".$Register_Delivery_Street_Address."', '".$Register_Delivery_Street_Address_2."', '".$Register_Delivery_Town_City."', '".$Register_Delivery_County."', '".$Register_Delivery_Post_Code."', '".$Register_Telephone_Number."');");
            if(!
    $Insert_User){
                echo 
    "Cannot add user: ".mysql_error();
            }else{
                echo 
    "You are successfully registered. Please Login below";
            }
        }else{
            
    $backurl "?page=members&register&error_count=".$Error_Count;
            
    $backurl .= "&Register_Full_Name=".$Register_Full_Name;
            
    $backurl .= "&Register_Email_Address=".$Register_Email_Address;
            
    $backurl .= "&Register_Username=".$Register_Username;
            
    $backurl .= "&Register_Street_Address=".$Register_Street_Address;
            
    $backurl .= "&Register_Street_Address_2=".$Register_Street_Address_2;
            
    $backurl .= "&Register_Town_City=".$Register_Town_City;
            
    $backurl .= "&Register_County=".$Register_County;
            
    $backurl .= "&Register_Post_Code=".$Register_Post_Code;
            
    $backurl .= "&Register_Delivery_Street_Address=".$Register_Delivery_Street_Address;
            
    $backurl .= "&Register_Delivery_Street_Address_2=".$Register_Delivery_Street_Address_2;
            
    $backurl .= "&Register_Delivery_Town_City=".$Register_Delivery_Town_City;
            
    $backurl .= "&Register_Delivery_County=".$Register_Delivery_County;
            
    $backurl .= "&Register_Delivery_Post_Code=".$Register_Delivery_Post_Code;
            
    $backurl .= "&Register_Telephone_Number=".$Register_Telephone_Number;
            foreach(
    $Problem_Fields as $key => $value){
                
    $backurl .= "&".$key."_Error=".$value;
            }
            
    header("location: ".$backurl);

        }

    Thanks in advance,

    Jake Arkinstall
    Last edited by Jake Arkinstall; Jul 25, 2007 at 04:13. Reason: Solved
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2006
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried out putting the $_POST['Register_Repeat_Password'];?
    Just to make sure there is a value.

    The empty value maybe causing a problem in step1()


    Sinky

  3. #3
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It doesn't matter now, I've solved it. Turns out the verification method for the email address used a function only used on Linux servers, and Error_Reporting was off so it didn't display the error.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •