We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 1,732 Posts
    ok awesome so i am almost done, just one last little problem. The internalKey is not a auto-incrementing key nor can it be since the id column is already. i need to figure out how to increment this to match the id column, or to copy the id key into the internalKey column. i know there is a way to count the rows and turn that into a variable, just not sure how to do it yet.


    You must first insert a record into web_users then use the new id value from the web_users to insert a record into the internalkey inside the web_user_attributes table.
      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 12878
      • 21 Posts
      ok well I am still unable to get the internalKey to update properly. it always stays at 0.

      do you see anything that would be causing this in the code?

        // add user
      if($action=='addUser') 
      
      	{ 
      	$username = $_POST['username'];
      	$password = $_POST['password'];
      	$password2 = $_POST['password2'];
      	$company = $_POST['company'];
      	$fullname = $_POST['fullname'];
      	$email = $_POST['email'];
      	$city = $_POST['city'];
      	$state = $_POST['state'];
      	$phone = $_POST['phone'];
      
      	if($password==$password2)
      		{
      		$conn = mysql_connect("$dbhost","$dbuser","$dbpass") or die ("Cant connect to Database");
      
      		$db = mysql_select_db("$dbname") or die ("database gone.");
      
      
      		$sql1 = "INSERT INTO etomite_web_users (id, username, password) VALUES ('NULL', '$username', MD5('$password'))";
      		$result1 = mysql_query($sql1) or die ("SQL1 not working, couldn't insert user into db");
      		if($result1) 
      
      			{
      			$sql2 = "SELECT id FROM etomite_web_users WHERE username = '$username'";
      			$result2 = mysql_query($sql2) or die ("SQL2 not working, unable to retrieve 'internalKey' from db");
      			if($result2)
      				{			
      				$sql3 = "INSERT INTO etomite_web_user_attributes (id, internalKey, company, fullname, email, city, state, phone) VALUES ('NULL', '$result2', '$company', '$fullname', '$email', '$city', '$state', '$phone')";
      				$result3 = mysql_query($sql3) or die ("SQL3 not working, unable to add user attributes");
      				if($result3) 
      
      					{
      					header("Location: index.php?id=74");
      
      					}
      				} 
      
      			}
      		}
      	}
      


      Thanks again!!

      todd
        www.detroitunderground.net
        www.dtwaudi.com
        www.greymatterhosting.com
        new flash site in the works
        • 32963
        • 1,732 Posts
        This sould do the trick

          // add user 
        if($action=='addUser')
        { 
           $username = $_POST['username']; 
           $password = $_POST['password']; 
           $password2 = $_POST['password2']; 
           $company = $_POST['company']; 
           $fullname = $_POST['fullname']; 
           $email = $_POST['email']; 
           $city = $_POST['city']; 
           $state = $_POST['state']; 
           $phone = $_POST['phone']; 
        
           if($password==$password2)
           { 
              $conn = mysql_connect("$dbhost","$dbuser","$dbpass") or die ("Cant connect to Database"); 
        
              $db = mysql_select_db("$dbname") or die ("database gone."); 
        
              $sql1 = "INSERT INTO etomite_web_users (id, username, password) VALUES ('NULL', '$username', MD5('$password'))"; 
              $result1 = mysql_query($sql1) or die ("SQL1 not working, couldn't insert user into db"); 
              if($result1)
              { 
              		// NOTE: this is how you get the new id		
              		$id = mysql_insert_id(); 
              		
                    $sql3 = "INSERT INTO etomite_web_user_attributes (id, internalKey, company, fullname, email, city, state, phone) VALUES ('NULL', '$id', '$company', '$fullname', '$email', '$city', '$state', '$phone')"; 
                    $result3 = mysql_query($sql3) or die ("SQL3 not working, unable to add user attributes"); 
                    if($result3)
                    { 
                    	header("Location: index.php?id=74"); 
                    } 
         	  } 
        	}
        }
        
          xWisdom
          www.xwisdomhtml.com
          The fear of the Lord is the beginning of wisdom:
          MODx Co-Founder - Create and do more with less.
          • 12878
          • 21 Posts
          thanks a lot! that worked like a charm!

          oh and i will add the finished file to the download posted above.

          todd
            www.detroitunderground.net
            www.dtwaudi.com
            www.greymatterhosting.com
            new flash site in the works
            • 12878
            • 21 Posts
            trying to add some validation to make sure all forms are filled out and i am runing into snag. it is still allowing registration even though all fields arent filled out.

            can anyone lend a hand?

            here is the code:

              // add user
            if($action=='addUser')
            {
               $username = $_POST['uname'];
               $password = $_POST['pwd'];
               $password2 = $_POST['pwd2'];
               $company = $_POST['company'];
               $fullname = $_POST['fullname'];
               $email = $_POST['email'];
               $city = $_POST['city'];
               $state = $_POST['state'];
               $phone = $_POST['phone'];
               $referredby = $_POST['referredby'];
            
               if(!isset($_POST['uname']) || !isset($_POST['pwd']) || !isset($_POST['company']) || !isset($_POST['fullname']) || !isset($_POST['email']) || !isset($_POST['city']) || !isset($_POST['state']) || !isset($_POST['phone']) || !isset($_POST['referredby']))
               { 
            
                  header("Location: index.php?id=92&p=yo"); 
            
               } 
            
                  if($username!='')
                  {
                     if($password==$password2)
                     {
                        $conn = mysql_connect("$dbhost","$dbuser","$dbpass") or die ("Cant connect to Database");
                        $db = mysql_select_db("$dbname") or die ("database gone.");
                        $sql1 = "INSERT INTO etomite_web_users (id, username, password) VALUES ('NULL', '$username', MD5('$password'))";
                        $result1 = mysql_query($sql1) or die ("SQL1 not working, couldn't insert user into db");
                        if($result1)
                        {     
                           $id = mysql_insert_id();
                           $sql3 = "INSERT INTO etomite_web_user_attributes (id, internalKey, company, fullname, email, city, state, phone, referredby) VALUES ('NULL', '$id', '$company', '$fullname', '$email', '$city', '$state', '$phone', '$referredby')";
                           $result3 = mysql_query($sql3) or die ("SQL3 not working, unable to add user attributes");
                           if($result3)
                           {
                              $sql4 = "INSERT INTO etomite_web_groups (id, webgroup, webuser) VALUES ('NULL', '1', '$id')";
                              $result4 = mysql_query($sql4) or die ("SQL4 not working, unable to add group attributes");
                              if($result4)
                              {
                                 $sql5 = "INSERT INTO etomite_web_user_settings (webuser, setting_name, setting_value) VALUES ('$id', 'login_home', '81')";
                                 $result5 = mysql_query($sql5) or die ("SQL5 not working, unable to add user settings");
                                 if($result4)
                                 {
                                    $sender = '[email protected]';
                                    $emailto = '[email protected]';
                                    $sub = 'New xxxx User Created';
                                    $sub2 = 'Your xxxx Login Credentials';
                                    $message = $fullname." has just signed up to xxx xxx The new users information is listed below."."\n\n"."Username = $username"."\n\n"."Company Name = $company"."\n\n"."Full Name = $fullname"."\n\n"."Email Address = $email"."\n\n"."City = $city"."\n\n"."State = $state"."\n\n"."Phone Number = $phone"."\n\n"."Referred By = $referredby"."\n\n";
                                    $message2 = "Welcome ".$fullname.". Thank you for signing up to xxx xxx Your login information is listed below."."\n\n"."Username = $username"."\n\n"."Password = $password"."\n\n"."HOME PAGE: http://www.xxx.com/"."\n\n";
                                    $header = "From: ".$sender."\n";
                                    $header .= "Reply-To: ".$sender."\n";
                                    mail($emailto, $sub, $message, $header);
                                    mail($email, $sub2, $message2, $header);
                                    header("Location: index.php?id=74");
                                 }
                              }
                           }
                        }
                     }
                     else
                     {
                        header("Location: index.php?id=80");
                     }
                  }
                  else
                  {
                     header("Location: index.php?id=92");
                  }
               
            }
            
              www.detroitunderground.net
              www.dtwaudi.com
              www.greymatterhosting.com
              new flash site in the works
              • 32963
              • 1,732 Posts
              trying to add some validation to make sure all forms are filled out and i am runing into snag. it is still allowing registration even though all fields arent filled out.

              can anyone lend a hand?


              Hi,

              See the WebSignup snippet found in the Tech Preview
                xWisdom
                www.xwisdomhtml.com
                The fear of the Lord is the beginning of wisdom:
                MODx Co-Founder - Create and do more with less.