Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4000934
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:50:35+00:00 2026-05-20T07:50:35+00:00

Below is the drupal custom modules, can u please confirm it, is it correct

  • 0

Below is the drupal custom modules,

can u please confirm it,

is it correct way of developing the custom module,

else please advise,

<?php
/**
*  Implementation of hook_form_alter().
*/
function register_form_alter(&$form, $form_state, $form_id) {
  switch($form_id) {
      case 'user_register': // the value we stole from the rendered form
        // your customizations go here
         // drupal_set_message('Hey, we\'ve tapped into this form!');
         $form['account']['bharani'] = array(
            '#title' => 'bharani',
            '#type' => 'textfield',
            '#description' => t(' bharanikumar custom field '),
          );
         $form['#submit'][] = 'register_submit_handler'; // Add this

      break;
  }
}

function register_submit_handler($form, &$form_state) {
  $value = $form_state['values']['bharani'];
  $mail = $_POST['mail'];
  $query  = "UPDATE users SET language='$value' WHERE mail='$mail'";
  db_query($query);
}


?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:50:36+00:00Added an answer on May 20, 2026 at 7:50 am

    I will not answer the “correct way of developing the custom module” part of the question, but here is a note about the way you’re doing your SQL query :

    You are using this :

    $value = $form_state['values']['bharani'];
    $mail = $_POST['mail'];
    $query  = "UPDATE users SET language='$value' WHERE mail='$mail'";
    db_query($query);
    

    With this, your code is subject to SQL-injections : no matter what the users will send into $_POST['mail'], it’ll endup in the query, un-escaped !

    With Drupal and db_query(), you should, instead, use something like this :

    $value = $form_state['values']['bharani'];
    $mail = $form_state['values']['mail'];;
    $query  = "UPDATE users SET language='%s' WHERE mail='%s'";
    db_query($query, $value, $mail);
    

    This way, Drupal will take care of the escaping, protecting you from SQL-injections.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to drupal. Is there any way to list in my custom-node.tpl.php what
I have a custom form implemented in a custom module in drupal 6. The
There was a module for drupal that I just can't seem to find now.
SORTED http://drupal.org/node/467190#comment-2068324 Hi friends, I've spent all day to find but can't find :(
I'm a drupal newbie... I have created a block with View Module to list
I'm trying to create a custom form in Drupal 6 and everything seems to
On Drupal 6 using a Zen subtheme, our custom stylesheet is beautiful and perfect
I have a custom module and I want a field to upload a picture.
Good Evening, I'm using Drupal 6, CCK Module, and the Link Field Type. All
We upgraded our core modules just fine. We then upgraded Ctools and Date module

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.