Thursday, January 23, 2014

Add More fields to a form using jquery/javascript in PHP


How can I make a form in php that allows the user to add additional form fields if they need them | Allow to add more fields to form | Inserting multiple form fields with same name | Dynamically Add Input Fields And Submit To Database With jQuery and PHP and fetch values of these fields on updation | Add more input fields to PHP form | Step by step example of add more same fields in PHP

Add More same fields to a form using jquery/javascript in PHP and insert into mysql database and fetch data when update form

 
















Step 1

Add min js in your header or proper location before using javascript code like:-
jquery-1.9.1.min.js OR higher

Step 2

write javascript/jquery code for add fields when click on plus(+) button and remove fields when click on Minus(-) button


Step 3

Add one row of fields between form. You can add more fields according to you


// query for fetch record on update time
$sql_desc="select po_item,po_qty ,po_rate ,po_vat ,po_cst,po_s_tax,po_total from "._DB_PREFIX."po_desc where po_id='$id'";
$qry0=mysql_query($sql_desc);
//end query for fetch record on update time

// query for fetch VAT amount and description for different goods/item
$sql_vat="select tax_amount,description from "._DB_PREFIX."tax where tax_type='VAT' and status='1'";

$qry1=mysql_query($sql_vat);
// end query for fetch VAT amount and description for different

// query for fetch CST amount and description for different goods/item
$sql_cst="select tax_amount,description from "._DB_PREFIX."tax where tax_type='CST' and status='1'";

$qry2=mysql_query($sql_cst);
// end
query for fetch CST amount and description for different
goods/item

// query for fetch service tax amount and description for different goods/item
$sql_ser_tax="select tax_amount,description from "._DB_PREFIX."tax where tax_type='Service Tax' and status='1'";

$qry3=mysql_query($sql_ser_tax);
// end
query for fetch Service Tax amount and description for different
goods/item

 $l=0;
while($row1=mysql_fetch_assoc($qry0)){

$sql_vat="select tax_amount,description from "._DB_PREFIX."tax where tax_type='VAT' and status='1'";
$qry1=mysql_query($sql_vat);

$sql_cst="select tax_amount,description from "._DB_PREFIX."tax where tax_type='CST' and status='1'";
$qry2=mysql_query($sql_cst);

$sql_ser_tax="select tax_amount,description from "._DB_PREFIX."tax where tax_type='Service Tax' and status='1'";
$qry3=mysql_query($sql_ser_tax);

//dynamically draw VAT option in dropdown
$vatOption1='';
while($row_pr_vat=mysql_fetch_assoc($qry1)){
//echo 'gvhfg';
extract($row_pr_vat);

$vatOption1 .= "";
}
// end dynamically draw VAT option in dropdown

//dynamically draw CST option in dropdown
$cstOption1='';

while($row_pr_cst=mysql_fetch_assoc($qry2)){

extract($row_pr_cst);

$cstOption1 .= "";
}

// End dynamically draw CST option in dropdown



//Dynamically draw service tax option in dropdown
$ser_taxOption1='';
while($row_pr_stax=mysql_fetch_assoc($qry3)){

extract($row_pr_stax);

$ser_taxOption1 .= "";
} 
//End dynamically draw service tax option in dropdown list
//for update records

if($id!=''){ ?> <br /> <br /> <label for="p_scnts"><input class="input-type-js input-type2" id="txt_desc_<?php echo $l;?>" name="txt_desc[]" placeholder="Description" size="20" style="width: 145px;" type="text" value="<?php echo $row1['po_item'];?>" /></label><br /> <label for="p_scnts"><input class="input-type-js input-type" id="txt_qty_<?php echo $l;?>" name="txt_qty[]" onkeypress="return isNumber(event)" placeholder="Qty" style="width: 29px;" type="text" value="<?php echo $row1['po_qty'];?>" /></label><br /> <label for="p_scnts"><input class="input-type-js input-type" id="txt_rate_<?php echo $l;?>" name="txt_rate[]" onkeypress="return isNumberKey(this.value);" placeholder="Rate" style="size: 8px;" type="text" value="<?php echo $row1['po_rate'];?>" /></label><br /> <br /> <label for="p_scnts"><select class="input-type-js input-type" id="sel_vat_<?php echo $l;?>" name="sel_vat[]"><option value="0.00">VAT</option> echo $vatOption1;?> </select></label><br /> <label for="p_scnts"><select class="input-type-js input-type" id="sel_cst_<?php echo $l;?>" name="sel_cst[]"><option value="0.00">CST</option> </select></label><br /> <label for="p_scnts"><select class="input-type-js input-type" id="sel_service_tax_<?php echo $l;?>" name="sel_service_tax[]"><option value="0.00">Service Tax</option> </select></label><br /> <label for="p_scnts"><input class="input-type-net input-type" id="txt_total_<?php echo $l;?>" name="txt_total[]" placeholder="Total" readonly="readonly" size="8" type="text" value="<?php echo $row1['po_total'];?>" /></label><br /> <br /> <br /> <br /> <br /> <br /> }
///end update records
else
{ ?>  //for add new fields
<br /> <label for="p_scnts"><input class="input-type-js input-type2" id="txt_desc_0" name="txt_desc[]" placeholder="Description" size="20" style="width: 145px;" type="text" value="" /></label><br /> <label for="p_scnts"><input class="input-type-js input-type" id="txt_qty_0" name="txt_qty[]" onkeypress="return isNumber(event)" placeholder="Qty" style="width: 29px;" type="text" value="" /></label><br /> <label for="p_scnts"><input class="input-type-js input-type" id="txt_rate_0" name="txt_rate[]" onkeypress="return isNumberKey(this.value);" placeholder="Rate" style="size: 8px;" type="text" value="" /></label><br /> <br /> <label for="p_scnts"><select class="input-type-js input-type" id="sel_vat_0" name="sel_vat[]" value=""><option value="">VAT</option> </select></label><br /> <label for="p_scnts"><select class="input-type-js input-type" id="sel_cst_0" name="sel_cst[]" value=""><option value="">CST</option> </select></label><br /> <label for="p_scnts"><select class="input-type-js input-type" id="sel_service_tax_0" name="sel_service_tax[]" value=""><option value="">Service Tax</option> </select></label><br /> <label for="p_scnts"><input class="input-type-net input-type" id="txt_total_0" name="txt_total[]" placeholder="Total" readonly="readonly" size="8" type="text" value="" /></label><br /> <br /> <br /> <br /> <br />

Wednesday, January 1, 2014

Validate required field in php or server side validation in php if javascript failed by client side


//add this function on function.php or other give other file name you are including on php page

function checkRequiredPost($requiredField) {
    $numRequired = count($requiredField);
    $keys        = array_keys($_POST);
    $allFieldExist  = true;
   
    foreach($requiredField as $reqr)
   
    {
        if($_POST[trim($reqr)]==''){$allFieldExist=false;break;}
    }
   
    return $allFieldExist;
}


// use below code before insert/update  query

$required=array('txt_name','txt_password'); // add fields name you want to mandatory them like name,password etc.

if(isset($_POST['submit']) && checkRequiredPost($required))

{
 ////type your code or insert/update query

}


Friday, December 27, 2013

WRITE PHP CODE IN CKEDITOR SORCE CODE AND FETCH IT ON USER PANEL (FRONT END)

You want to fetch news or other records records in front end(user panel)

                                                       
                                                    while($res=mysql_fetch_array($
qry))    {
                                                    echo ''.  $res['headline'].'....

';
                                                    } ?>




/*write php code in ckeditor use below script on page where you use ckeditor after textarea control*/
   */
            CKEDITOR.replace( 'editor1',
    {
        filebrowserUploadUrl : 'http://127.0.0.1/Hope/admin/images/upload.php'
        //filebrowserUploadUrl : 'http://127.0.0.1/Hope/admin/images/upload.php'
    });

           
-->

//for fetching records to userpanel page  use eval function with below  type or example.

 echo eval('?>' . utf8_encode($rst['content']) . ' //echo $rst['content'];
 

 ?>
 ---------------------------------------

Friday, December 13, 2013

Insert hindi text to mysql database

1. open phpmyadmin
2. Click on SQL tab or select any database name then 
Click on SQL tab
3. copy below sql query one by one and paste in SQL body  
 
mysql_query('SET character_set_results=utf8');

mysql_query('SET names=utf8');
mysql_query('SET character_set_client=utf8');

mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_results=utf8');

mysql_query('SET collation_connection=utf8_general_ci');
 
 
 
 
 
 
 
 
 
 
 
4. And click on GO Button to execute above query.
 
 

-->

Saturday, May 5, 2012

How to rename the WordPress wp-admin folder to New Name like sitehandler


step1. Install first wordpress with proper database name and login. you can login in admin area using http://127.0.0.1/your_word_press_folder(site)_name/wp-admin

you can change wp-admin name to other any name like sitehandler


step2. Open wordpress or site folder and select only all php files and open in dreamweaver after this open find and replace dialoge(ctrl+f) type in find wp-admin and  in replace type sitehandler(or other name as you wish) select find in open documents(changes only opened document) and click on replace all after this save all document in file menu and press ctrl+shift+w


step3.
open wp-includes folder and select only all Php files and find and replace wp-admin with sitehandler
           and save all files and close all files using ctrl+shift+w.

step4. open wp-includes/css , wp-includes/js, wp-includes/pomo, wp-includes/Text, wp-includes/theme-compat all php files and find and replace wp-admin with sitehandler
and save all files and close all files using ctrl+shift+w.

step5.  open all files of wp-content folder and find and replace wp-admin with sitehandler and save all files and close all files using ctrl+shift+w.

step6.  open all files of wp-admin folder and select and open  all php files find and replace wp-admin with sitehandler and save all files and close all files using ctrl+shift+w.

step7. open all folders(css, includes, js, maint, network, user) of wp-admin and open  all php files find and replace wp-admin with sitehandler and save all files and close all files using ctrl+shift+w.

step8.  rename wp-admin/css css files naming wp-admin.css-->sitehandler.css, wp-admin.dev.css -->sitehandler.dev.css, wp-admin-rtl.css-->sitehandler-rtl.css, wp-admin-rtl.dev.css-->sitehandler-rtl.dev.css

step9. change wp-admin folder name to sitehandler

step10. change file name class-wp-admin-bar.php to class-sitehandler-bar.php in wp-includes folder.

Tuesday, March 16, 2010

Connect internet using Reliance datacard in Windows7


1. First Connect Your Reliance Data card to PC (USB Port) & install the modem(Software).
2. After installing Software use the following step
a) Open Control Panel-> Click on 'switch the classic view. b) or directly open Network Connection and click on create a new connection.
3. After this use the following method.













4. After this connect to Reliance 2 and click on dial & enjoy............................

Monday, October 19, 2009

how to insert image/photo/graphics in message text body

if you don't want to attach a image file(jpeg,gif,bmp etc.) in your mail(text body).
Then you can paste your image in text body without any attachment. copy paste process is given below.

1. Right click on image file
2. choose open with internet explorer.
3. or Choose program... then choose internet explorer.
4. Press enter key or click on ok button.
5. In internet explorer(browser window) right click on image and copy image.
6. after this paste image in your(Gmail, Yahoo etc.) mail box tex body.
7. Do practical right now and send mail without image attachement.