DBTS Admin Object/WB Login System **UPDATED June 19,2010***

In this section you can share self-made extensions with other users of WYSIWYG Web Builder.

There are already more than 250 extensions available!
User avatar
Navaldesign
 
 
Posts: 1008
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Re: DBTS Admin Object/WB Login System ***UPDATED June 19,201

Post by Navaldesign » Sun Oct 31, 2010 9:19 pm

Then, most probably, the user you have created has no permissions to read / write in the database.

Check it, allow your Database user ALL permissions to the specific database, and test again.

Was the table automatically created ? or did you create it manually ?
www.dbtechnosystems.com

User avatar
Patrik iden
 
 
Posts: 538
Joined: Wed Mar 24, 2010 9:07 pm
Location: Sweden

Re: DBTS Admin Object/WB Login System ***UPDATED June 19,201

Post by Patrik iden » Sun Oct 31, 2010 9:31 pm

The table was created automaticly whit your extention.
How do i grant ALL permission to the databas?

User avatar
Navaldesign
 
 
Posts: 1008
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Re: DBTS Admin Object/WB Login System ***UPDATED June 19,201

Post by Navaldesign » Sun Oct 31, 2010 9:44 pm

If th etable was created automatically, you probably have the correct permissions.

To check it, and see what permissions the user actually has, you need to go in your hosting account CPanel, Databases section, and ADD again the user to the database, the wizard should dislay the uer's permissions and there you can select "ALL".
www.dbtechnosystems.com

User avatar
Patrik iden
 
 
Posts: 538
Joined: Wed Mar 24, 2010 9:07 pm
Location: Sweden

Re: DBTS Admin Object/WB Login System ***UPDATED June 19,201

Post by Patrik iden » Sun Oct 31, 2010 10:08 pm

OK, i'l try that.

In youe extention, what is this?

latin1_german1_ci
latin1

brassnugget
 
 
Posts: 39
Joined: Sun Feb 22, 2009 1:59 am

Signup page additional fields

Post by brassnugget » Tue Nov 09, 2010 9:46 am

Is it possible to add custom fields to the signup page which are then recorded/updated in the MySQL database for that user?

(am using the DBTS MySQL Admin and Login extensions)

User avatar
Navaldesign
 
 
Posts: 1008
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Re: DBTS Admin Object/WB Login System ***UPDATED June 19,201

Post by Navaldesign » Tue Nov 09, 2010 11:33 am

Yes, it is possible.

Please read this tutorial: http://www.wysiwygwebbuilder.com/customize_signup.html

In time, a DBTS Signup object will be available to make this task easier.
www.dbtechnosystems.com

brassnugget
 
 
Posts: 39
Joined: Sun Feb 22, 2009 1:59 am

Re: DBTS Admin Object/WB Login System ***UPDATED June 19,201

Post by brassnugget » Tue Nov 09, 2010 9:17 pm

Thanks Naval, I figured it was going to be something like that but was hoping for something more fool proof :D

I want to add in a new variable making use of radio buttons eg What is your gender: Male, Female

I have converted the standard signup extension to a form

The example variable code supplied in the tutorial (to be placed in the html code 'signup') is for editboxes, can I use the same code layout for radio buttons? eg

Code: Select all

$city = $_POST['city'];
When it comes to specifying the database name for the non MySQL extension the correct way of supplying it was ./mydatabase.php, what is the correct way of supplying the MySQL database details into the html 'signup' code.

Cheers

User avatar
Navaldesign
 
 
Posts: 1008
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Re: DBTS Admin Object/WB Login System ***UPDATED June 19,201

Post by Navaldesign » Tue Nov 09, 2010 9:43 pm

Yes, the code is similar to that for editboxes-

MySQL Details: depends on your hosting account. Click on the Signup object properties
Usually:

Server = 'localhost'; (usually
Username = 'dbuser';
Password = 'dbpassword';
Database = 'dbname';
Table = 'users';

dbuser, dbpassword, dbname are the details of the MySQL database that you MUST create in your cpanel before this can work.

If you have converted the form, then the code is in the HTML box beside the form.
You will see the following code:


$mysql_server = 'localhost';
$mysql_username = 'dbuser';
$mysql_password = 'dbpassword';
$mysql_database = 'dbname';
$mysql_table = 'users';


Change the settings accordingto your real database details.
www.dbtechnosystems.com

brassnugget
 
 
Posts: 39
Joined: Sun Feb 22, 2009 1:59 am

Re: DBTS Admin Object/WB Login System ***UPDATED June 19,201

Post by brassnugget » Wed Nov 10, 2010 4:12 am

Thanks Naval,

I couldn't see the MySQL database settings in the HTML box because I hadn't enabled the database before converting it to a form.

In my modifications I must have done some incorrect coding because only the admin is receiving a signup email and a new user is not displayed in the secure admin area (admin extension).

Would you mind having a look at my HTML box code from the signup page and see if you can put me right (MySQL database info & email addresses removed). Variables: S e x, Age_group, & Colour_bow are radio button fields (do I need to add the possible responses eg for S e x: $Male = $_POST['Male'];)?

Thank you

Code: Select all

<?php
$error_message = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
   $action = isset($_POST['action']) ? $_POST['action'] : '';
   $mysql_server = 'localhost';
   $mysql_username = 'removed';
   $mysql_password = 'removed';
   $mysql_database = 'removed';
   $mysql_table = 'removed';

   $success_page = './account_pending.php';

   if ($action == 'signup')
   {
      $newusername = $_POST['username'];
      $newemail = $_POST['email'];
      $newpassword = $_POST['password'];
      $confirmpassword = $_POST['confirmpassword'];
      $newfullname = $_POST['fullname'];
      $citytown = $_POST['citytown'];
      $*** = $_POST['***'];
      $Age_group = $_POST['Age_group'];
      $Colour_bow = $_POST['Colour_bow'];
      if ($newpassword != $confirmpassword)
      {
         $error_message = 'Password and Confirm Password are not the same!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newusername))
      {
         $error_message = 'Username is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newpassword))
      {
         $error_message = 'Password is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $newfullname))
      {
         $error_message = 'Fullname is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $citytown))
      {
         $error_message = 'The entered City or Town name is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $***))
      {
         $error_message = 'The selection is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $Age_group))
      {
         $error_message = 'The selection is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $Colour_bow))
      {
         $error_message = 'The selection is not valid, please check and try again!';
      }
      if (!ereg("^.+@.+\..+$", $newemail))
      {
         $error_message = 'Email is not a valid email address. Please check and try again.';
      }
      if (empty($error_message))
      {
         $db = mysql_connect($mysql_server, $mysql_username, $mysql_password);
         mysql_select_db($mysql_database, $db);
         $sql = "SELECT username FROM ".$mysql_table." WHERE username = '".$newusername."'";
         $result = mysql_query($sql, $db);
         if ($data = mysql_fetch_array($result))
         {
            $error_message = 'Username already used. Please select another username.';
         }
      }
      if (empty($error_message))
      {
         $crypt_pass = md5($newpassword);
         $sql = "INSERT `".$mysql_table."` (`username`, `password`, `fullname`, `email`, `active`, `citytown`, `***`, `Age_group`, `Colour_bow`) VALUES ('$newusername', '$crypt_pass', '$newfullname', '$newemail', 1, '$citytown', '$***', '$Age_group', '$Colour_bow')";
         $result = mysql_query($sql, $db);
         mysql_close($db);
         $mailto = $newemail;
         $subject = 'New Account';
         $message = Account pending';
         $message .= "\r\nUsername: ";
         $message .= $newusername;
         $message .= "\r\nPassword: ";
         $message .= $newpassword;
         $message .= "\r\n";
         $header  = "From: removed for this example"."\r\n";
         $header .= "Reply-To: removed for this example"."\r\n";
         $header .= "MIME-Version: 1.0"."\r\n";
         $header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
         $header .= "Content-Transfer-Encoding: 8bit"."\r\n";
         $header .= "X-Mailer: PHP v".phpversion();
         mail('removed for this example, $subject, $message, $header);
         header('Location: '.$success_page);
         exit;
      }
   }
}
?>

User avatar
Navaldesign
 
 
Posts: 1008
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Re: DBTS Admin Object/WB Login System ***UPDATED June 19,201

Post by Navaldesign » Wed Nov 10, 2010 7:12 am

Code: Select all



<?php
$error_message = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
   $action = isset($_POST['action']) ? $_POST['action'] : '';
   $mysql_server = 'localhost';
   $mysql_username = 'removed';
   $mysql_password = 'removed';
   $mysql_database = 'removed';
   $mysql_table = 'removed';

   $success_page = './account_pending.php';

   if ($action == 'signup')
   {
      $newusername = $_POST['username'];
      $newemail = $_POST['email'];
      $newpassword = $_POST['password'];
      $confirmpassword = $_POST['confirmpassword'];
      $newfullname = $_POST['fullname'];
      $citytown = $_POST['citytown'];
      $gender = $_POST['gender'];
      $age_group = $_POST['age_group'];
      $colour_bow = $_POST['colour_bow'];
      if ($newpassword != $confirmpassword)
      {
         $error_message = 'Password and Confirm Password are not the same!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newusername))
      {
         $error_message = 'Username is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newpassword))
      {
         $error_message = 'Password is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $newfullname))
      {
         $error_message = 'Fullname is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $citytown))
      {
         $error_message = 'The entered City or Town name is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $gender))
      {
         $error_message = 'The selection is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $age_group))
      {
         $error_message = 'The selection is not valid, please check and try again!';
      }
      else
      if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $colour_bow))
      {
         $error_message = 'The selection is not valid, please check and try again!';
      }
      if (!ereg("^.+@.+\..+$", $newemail))
      {
         $error_message = 'Email is not a valid email address. Please check and try again.';
      }
      if (empty($error_message))
      {
         $db = mysql_connect($mysql_server, $mysql_username, $mysql_password);
         mysql_select_db($mysql_database, $db);
         $sql = "SELECT username FROM ".$mysql_table." WHERE username = '".$newusername."'";
         $result = mysql_query($sql, $db);
         if ($data = mysql_fetch_array($result))
         {
            $error_message = 'Username already used. Please select another username.';
         }
      }
      if (empty($error_message))
      {
         $crypt_pass = md5($newpassword);
         $sql = "INSERT `".$mysql_table."` (`username`, `password`, `fullname`, `email`, `active`, `citytown`, `gender`, `age_group`, `colour_bow`) VALUES ('$newusername', '$crypt_pass', '$newfullname', '$newemail', 1, '$citytown', '$gender', '$age_group', '$colour_bow')";
         $result = mysql_query($sql, $db);
         mysql_close($db);
         $mailto = $newemail;
         $subject = 'New Account';
         $message = 'Account pending';
         $message .= "\r\nUsername: ";
         $message .= $newusername;
         $message .= "\r\nPassword: ";
         $message .= $newpassword;
         $message .= "\r\n";
         $header  = "From: removed for this example"."\r\n";
         $header .= "Reply-To: removed for this example"."\r\n";
         $header .= "MIME-Version: 1.0"."\r\n";
         $header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
         $header .= "Content-Transfer-Encoding: 8bit"."\r\n";
         $header .= "X-Mailer: PHP v".phpversion();
         mail($mailto, $subject, $message, $header);
         mail('youremail@yourdomain.com', $subject, $message, $header);
         header('Location: '.$success_page);
         exit;
      }
   }
}
?>

I have replaced "s e x" with "gender" and lower cased all fields, you need to change accordingly your form.

Please note that this is not standard support, debugging user issues of this type requires too much time.
www.dbtechnosystems.com

brassnugget
 
 
Posts: 39
Joined: Sun Feb 22, 2009 1:59 am

Re: DBTS Admin Object/WB Login System ***UPDATED June 19,201

Post by brassnugget » Wed Nov 10, 2010 8:49 am

THANK YOU VERY MUCH NAVAL!!! :D

Two more questions if you have a moment: in the MySQL database admin there are the two fields 'Creation Date' and 'Expiry Date'.

Is it possible to have say a hidden editbox on the signup form that 'displays' the current date, which in turn is submitted to the database as the 'Creation Date', if so is it then possible for me to somehow automatically specify for all signups that the 'Expiry Date' is x number of days after that user's 'Creation Date'?

User avatar
Navaldesign
 
 
Posts: 1008
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Re: DBTS Admin Object/WB Login System ***UPDATED June 19,201

Post by Navaldesign » Wed Nov 10, 2010 1:19 pm

Please note that the DBTS MySQL Admin object creates the database table by itself (you don't need to create it) and BY DESIGN it ads three standard fields apart the ones you might want to add yourself: creation_date, expiry_date, redirect.

So these columns already exist in the database table.

Now, regarding your question:

Add the following hidden fields / values in the form:

Field: creation_date

value: <?php echo date('Y-m-d');?>

Field: expiry date

value (all in one line or WB will truncate it):

<?php $time_period = "1 year"; $expiry = strtotime(date('Y-m-d')); $new_expiry = strtotime($time_period, $expiry); $expiry_date = date('Y-m-d', $new_expiry );echo $expiry_date;?>

You can replace "1 year" with any valid time period expression, like:

2 months
120 days
2 years
etc.

This will set the expiry to whatever period you set.
www.dbtechnosystems.com

brassnugget
 
 
Posts: 39
Joined: Sun Feb 22, 2009 1:59 am

Re: DBTS Admin Object/WB Login System **UPDATED June 19,2010

Post by brassnugget » Wed Nov 10, 2010 11:25 pm

Thank you very much Naval - this is a very useful extension.

Just a note for others who may want to do the same as above, the 'signup_date' label should actually be 'creation_date' (when using the default admin fields)

Now that I'm able to test everything fully I have come across an issue in relation to the admin area and making changes to a users stored information. Currently the password field in admin for a user is displayed as blank (I'm guessing that this is for security reasons however it would be nice for the admin to be able to view a users password), the problem that I've found is that when you update a users info eg manually change their full name etc and then save, it seems to override the users password value with (presumably) a blank value. So that after a change is made when I try to login to a protected page via the DBTS Login/login form I get the 'Either the username or password were not found on this database' error message.

I could login perfectly prior to the change being made to the users account info.

User avatar
Navaldesign
 
 
Posts: 1008
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Re: DBTS Admin Object/WB Login System **UPDATED June 19,2010

Post by Navaldesign » Thu Nov 11, 2010 5:52 am

You are right about the "creation_date"

The password becoming blank, instead, is not normal behavior.
In any case, displaying the password is meaningless, as it is encrypted, so what you would see has no sense and can't be used.
I will investigate this and apply necessary corrections to the code if necessary.
www.dbtechnosystems.com

User avatar
Navaldesign
 
 
Posts: 1008
Joined: Sat Mar 01, 2008 8:08 pm
Location: Italy
Contact:

Re: DBTS Admin Object/WB Login System **UPDATED June 19,2010

Post by Navaldesign » Thu Nov 11, 2010 6:20 am

I have checked the code and it should update the password details IF and ONLY IF the Admin submits a whatever value, if it remains empty it will not update the password.

This, on theoretical level.

I will check it in practical level (test the script) as soon as possible.
www.dbtechnosystems.com

Post Reply