Hi everyone I have developed Drupal website and custom registration form. The registration form is multi-step and in popup window so i m using lightbox2 module of drupal and working perfectly fine and the form code is written in the lightbox2 file that comes with module and place in theme folder, and multi-step i handeld with javascript that is also working fine but now i want to send ajax request when user fill the first part of form and click go to next part i send the ajax request to sites/all/theme/mytheme/template/insert.php when ajax request send it says access forbidden. Now tell me how i can use ajax to insert data in database ?

I have check the access forbidden from firebug.

Waiting for quick reply
Thanks

Re: Custom form data is not inserting in database using DRUPAL 80 80

Check your HTDOCS if you have a proper access to it .
Thats the first thing to do if you receive this kind of errors.

Re: Custom form data is not inserting in database using DRUPAL 80 80

I have complete access for HTDOCS and i have many other website that's work perfectly fine with ajax and everything this is the CMS the access forbidden is because i m not able to send ajax request in sites/all/themes/mytheme/mypage.tpl.php

and can i access the drupal database with other website means to say that can i show the data from drupal database in 2 different website ?

Re: Custom form data is not inserting in database using DRUPAL 80 80

and can i access the drupal database with other website means to say that can i show the data from drupal database in 2 different website ?

Yes, its possible to share specific tables in your drupal database in two different websites just by editing your settings.php

I have complete access for HTDOCS and i have many other website that's work perfectly fine with ajax and everything this is the CMS the access forbidden is because i m not able to send ajax request in sites/all/themes/mytheme/mypage.tpl.php

Maybe you cant send ajax request because you need some modules for ajax.
if i'm wrong try this : http://drupal.org/node/305747

Re: Custom form data is not inserting in database using DRUPAL 80 80

actually i m using simple js ajax function

function showCustomer(str)
{
var xmlhttp;
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getcustomer.asp?q="+str,true);
xmlhttp.send();
} // This code is copy from w3schools but mine have same a little bit different

i m not using any ajax module
and i m using custom form not mdoule means to say that i have form in simple html i have not use

function mymodule_example_form($form, &$form_state) {
  // Text field
  $form['name'] = array(
    '#title' => t('Your full name'),
    '#type' => 'textfield',
    '#required' => TRUE,
  );

tell me can i user simple html form and call an ajax to my own created simple php file that is insert.php ?
or i have to make form with above drupal function

Re: Custom form data is not inserting in database using DRUPAL 80 80

You better switch to jquery for easy debugging and clear codes ..

Re: Custom form data is not inserting in database using DRUPAL 80 80

Thank for your reply

Just tell me one thing that can i insert data in database with simple html form like below one

<input typy="text" id="first_name" name="first_name" />

<input typy="text" id="last_name" name="last_name" />

<input typy="email" id="email" name="email" />

<input typy="number" id="postcode" name="postcode" />

Or i have to use drupal method like below code.

function _handler_step_0($form, &$form_state) {

  $weight = 0;
  $form['first_name'] = array(
      '#type' => 'textfield',
      '#size' => 10,
      '#maxlength' => 10,
      '#title' => t('First Name'),
      '#weight'=>$weight++,
      '#prefix' => '<table border=0 cellspacing=3 celladding=3><tr><td>',
      '#suffix' => '</td>',
      '#default_value' => isset($form_state['storage']['first_name']) ? $form_state['storage']['first_name'] : '',
   );
  }

after the answer of above question then tell me if i use first method and write simple jquery ajax code in the same file where i have the form and on sumbit it send the ajax request like

$.ajax({

    type:"POST",
    url: "sites/all/themes/mytheme/templates/simple.tpl.php",
    data: dataString,
    cache: false,
    success: function(data){

        alert('data inserted successfully.');
    }
});

I use the above code and when the ajax request send the i check from firebug and it says access forbidden

Regards

MY FORM IS MULTI-STEP AND I M USING LIGHTBOX2 MODULE AND ITS WORKING PERFECTLY FINE ONLY THE ISSUE IS TO INSERT DATA IN MY CUSTOM TABLES WITH AJAX

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.