Wednesday 28 December 2016

How To Display Author Bio in WordPress

After login in WordPress login panel.


Add Social Media Profile Box To User Profile:-
Copy the below into your "functions.php" file to add input boxes for the user social media profiles.

/*=====================================================================    * Add Author Links
 * ====================================================================*/
function add_to_author_profile( $contactmethods ) {

$contactmethods['rss_url'] = 'RSS URL';
$contactmethods['google_profile'] = 'Google Profile URL';
$contactmethods['twitter_profile'] = 'Twitter Profile URL';
$contactmethods['facebook_profile'] = 'Facebook Profile URL';
$contactmethods['linkedin_profile'] = 'Linkedin Profile URL';

return $contactmethods;
}
add_filter( 'user_contactmethods', 'add_to_author_profile', 10, 1);

Then Go to Users -> Your Profile & manage information.


View Author Bio:-
Copy & paste Following code where you want so see.






Written by



Website:

    $rss_url = get_the_author_meta( 'rss_url' );
    if ( $rss_url && $rss_url != '' ) {
    echo '
  • ';
    }

    $google_profile = get_the_author_meta( 'google_profile' );
    if ( $google_profile && $google_profile != '' ) {
    echo '
  • ';
    }

    $twitter_profile = get_the_author_meta( 'twitter_profile' );
    if ( $twitter_profile && $twitter_profile != '' ) {
    echo ' ';
    }

    $facebook_profile = get_the_author_meta( 'facebook_profile' );
    if ( $facebook_profile && $facebook_profile != '' ) {
    echo ' ';
    }

    $linkedin_profile = get_the_author_meta( 'linkedin_profile' );
    if ( $linkedin_profile && $linkedin_profile != '' ) {
    echo '
  • ';
    }
    ?>




    Contact form 7 Email body HTML Structure code

    Style 1:-



    Enquiry from Website






    Name:
    [your-name]


    Email:
    [your-email]



    Contact No:
    [tel-no]



    Message:
    [your-message]







    This email sent from "#".



    BbPress links shortcode in WordPress

    Below given shortcode for
    Profile  => [BUDDYUSER-PROFILE text='Edit Profile']
    Friends  => [BUDDYUSER-FRIENDS text='My Friends']
    Activity => [BUDDYUSER-ACTIVITY text='My Activity']
    Add following code in your theme "functions.php" file.


    /** bbpress profile link shortdode "[BUDDYUSER-PROFILE text='Edit Profile']" **/
    add_shortcode( 'BUDDYUSER-PROFILE', 'cuser_profile_shortocode_handler' );
    function cuser_profile_shortocode_handler( $atts ){
    $atts = shortcode_atts( array(
    'text' => 'my profile',
    ), $atts );

    if( !is_user_logged_in() )
    return '';

    $link = home_url( '/members/' . bp_core_get_username( get_current_user_id() ) . '/profile/' );
    return "" . $atts['text'] . "";
    }


    /** bbpress friends link shortdode "[BUDDYUSER-FRIENDS text='My Friends']" **/
    add_shortcode( 'BUDDYUSER-FRIENDS', 'cuser_friends_shortocode_handler' );
    function cuser_friends_shortocode_handler( $atts_friends ){
    $atts_friends = shortcode_atts( array(
    'text' => 'my friends',
    ), $atts_friends );

    if( !is_user_logged_in() )
    return '';

    $link = home_url( '/members/' . bp_core_get_username( get_current_user_id() ) . '/friends/' );
    return "" . $atts_friends['text'] . "";
    }


    /** bbpress activity link shortdode "[BUDDYUSER-ACTIVITY text='My Activity']" **/
    add_shortcode( 'BUDDYUSER-ACTIVITY', 'cuser_activity_shortocode_handler' );
    function cuser_activity_shortocode_handler( $atts_activity ){
    $atts_activity = shortcode_atts( array(
    'text' => 'my activity',
    ), $atts_activity );

    if( !is_user_logged_in() )
    return '';

    $link = home_url( '/members/' . bp_core_get_username( get_current_user_id() ) . '/' );
    return "" . $atts_activity['text'] . "";
    }

    Any defined user role redirect to homepage after login in Wordpress

    Paste this function into your themes "functions.php" to redirect every specific user role from the admin back to your homepage:

    add_action('admin_init', function() {
       
        $wp_user = wp_get_current_user();
       
        if(isset($wp_user->caps['subscriber']) && $wp_user->caps['subscriber']){
            wp_redirect(get_site_url());
            exit;
        }
       
    });


    Here, "subscriber" is user role slug change this as your user role.
    it can be author, contributor, editor,

    Create custom user roles in WordPress

    Methode 1:-

    Add following code in "functions.php" file


    // Add a custom user role

    $result = add_role( 'client', __('Client' ),
    array(
    'read' => true, // true allows this capability
    'edit_posts' => true, // Allows user to edit their own posts
    'edit_pages' => true, // Allows user to edit pages
    'edit_others_posts' => true, // Allows user to edit others posts not just their own
    'create_posts' => true, // Allows user to create new posts
    'manage_categories' => true, // Allows user to manage post categories
    'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
    'edit_themes' => false, // false denies this capability. User can’t edit your theme
    'install_plugins' => false, // User cant add new plugins
    'update_plugin' => false, // User can’t update any plugins
    'update_core' => false // user cant perform core updates
    )
    );


    Methode 2:-

    Install "User Role Editor" plugin from "https://wordpress.org/plugins/user-role-editor/"

    Create an admin user by using database in WordPress

    1. To begin, log into your cPanel interface.

    2. From the main cPanel screen, find the Databases category and click on the icon entitled phpMyAdmin.

    3. Once the first screen appears, look to the left hand sidebar and click on the database for your specific WordPress installation. If you do not know which database is the correct one, you can find out by using these instructions.

    4. After the database information loads, you will need to find the tab named SQL and click on it.

    5. This leads you to an SQL editor where you will enter some code that will create a new admin account for you. Below is the code to create a new admin account named "newadmin" with the password "pass123". You may change any of the content in red to fit your needs, but leave all other data as is.


    INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
    VALUES ('newadmin', MD5('pass123'), 'firstname lastname', 'email@example.com', '0');

    INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
    VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

    INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
    VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');


    6. After replacing any data fields you need, click the Go button to perform the insertion.

    7. This should simply refresh the screen and you should see the messsage '1 row affected' after each of the three SQL statements. This means the insertion ran smoothly. From here, visit your wordpress admin login area as normal and use the new admin login information. You should get to the admin interface without issue.

    IF template name is this then do this in WordPress

    Just add following code where you need.


    if ( is_page_template('template_file_name.php') ) {
        // Returns true when 'template_file_name.php' is being used.
    } else {
        // Returns false when 'template_file_name.php' is not being used.
    }
    ?>

    Notice Undefined offset error Solution in WordPress

    Method 1:-

    Please deactivate the wp debug mode. Open up wp-config.php and replace:
    define( 'WP_DEBUG', true );
    with
    define( 'WP_DEBUG', false );



    Method 2:-

    Put following code in "functions.php" file.

    error_reporting(0);
    @ini_set(‘display_errors’, 0);

    Saturday 5 November 2016

    If Page specific id then code execute WordPress code?

    IT NEW CODE gives a way to execute some code on only fix page.
    We can do it by using page id.
    Below is given code.
    In this code if page id match then only code will be execute.


    Here, 156 id is page id

    Code is below:

    <?php
    if(is_page(156)){
    // Put Your code Here
    echo do_shortcode('[widget id="text-4"]');
    }
    ?>



    For more Interesting, Useful Article & codes visit IT New Code.
    IT NEW CODE always help you with new Developing Code.


    How to Hide WordPress Theme identity?

    IT NEW CODE gives to rename a theme as your project or website name.
    There are some steps to follow you.


    1> Add following code in "function.php" file.
    ----------------------------------------
    //
    // To hide WP header identity
    //
    remove_action('wp_head', 'wp_generator');


    //
    //To Change Name Howdy in wp Admin top right Corner
    //
    function change_howdy($translated, $text, $domain) {

        if (!is_admin() || 'default' != $domain)
            return $translated;

        if (false !== strpos($translated, 'Howdy'))
            return str_replace('Howdy', 'Welcome', $translated);

        return $translated;
    }
    add_filter('gettext', 'change_howdy', 10, 3);


    //
    // Admin Side CSS
    //
    function my_custom_css() {
    echo '<style>
    #wp-admin-bar-wp-logo ,#wpfooter, #dashboard_primary, #wp-version-message, .welcome-panel h2, .welcome-panel .about-description, #adminmenu .wp-has-current-submenu .wp-submenu {
        display: none;
    }
    </style>';
    }
    add_action('admin_head', 'my_custom_css');




    2> In "style.css" file following like code there.
    ----------------------------------------
    /*
    Theme Name: Twenty Fifteen
    Theme URI: https://wordpress.org/themes/twentyfifteen/
    Author: the WordPress team
    Author URI: https://wordpress.org/
    Description: Our 2015 default theme is clean, blog-focused, and designed for clarity. Twenty Fifteen's simple, straightforward typography is readable on a wide variety of screen sizes, and suitable for multiple languages. We designed it using a mobile-first approach, meaning your content takes center-stage, regardless of whether your visitors arrive by smartphone, tablet, laptop, or desktop computer.
    Version: 1.5
    License: GNU General Public License v2 or later
    License URI: http://www.gnu.org/licenses/gpl-2.0.html
    Tags: black, blue, gray, pink, purple, white, yellow, dark, light, two-columns, left-sidebar, fixed-layout, responsive-layout, accessibility-ready, custom-background, custom-colors, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready
    Text Domain: twentyfifteen

    This theme, like WordPress, is licensed under the GPL.
    Use it to make something cool, have fun, and share what you've learned with others.
    */


    In Above code Bold Letter value must be change. Others are optional.
    Must Change Theme Name, Theme URI, Author, Author URI value.



    For more Interesting, Useful Article & codes visit IT New Code.
    IT NEW CODE always help you with new Developing Code.

    How to add multiple header and footer in WordPress?


    IT NEW CODE give a trick to make multiple header & footer  templates.
    Sometimes We need multiple kind of look & client needs different header.
    In such a case need to create multiple header files.
    Below describes how to create multiple headwer & footer.

    Create New Header:-
    In Your theme defalt header file name as "header.php".
    You create new header file like,"header-cast.php"
    and put your code in it.

    Now How to call this in your template? just put following code where you want to add.

    <?php get_header('cast'); ?>


    Create New Footer:-
    Now, You can do same for footer.
    You create new footer like,"footer-cast.php"

    put following code to call it.

    <?php get_footer('cast'); ?>



    For more Interesting, Useful Article & codes visit IT New Code.
    IT NEW CODE always help you with new Developing Code.

    How to Disable auto formating?

    IT NEW CODE give trick to disable auto formatting paragraph tag <p>.



    To solve just like auto <p> tag generation problem add following code in your theme "function.php" file.

    <?php

    remove_filter( 'the_content', 'wpautop' );
    remove_filter( 'the_excerpt', 'wpautop' );

    ?>



    For more Interesting, Useful Article & codes visit IT New Code.
    IT NEW CODE always help you with new Developing Code.


    Thursday 3 November 2016

    How to Disable Ctrl+U?

    Sometimes to protect our website content from copy-paste & miss use of it or protect it from spam uses need some security. To check the code of webpage "Ctrl+U" is use.
    Below is given method to stop this code by script.
    Simply Add this code.

    Here Script is stop "Ctrl+U" by key code.
    Just put following code in Header section <head> tag.


    <!--------- Put this code in "<head>" tag ------------->

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script>
    document.onkeydown = function(e) {
            if (e.ctrlKey &&
                (e.keyCode === 67 ||
                 e.keyCode === 86 ||
                 e.keyCode === 85 ||
                 e.keyCode === 117)) {
                return false;
            } else {
                return true;
            }
    };
    $(document).keypress("u",function(e) {
      if(e.ctrlKey)
      {
    return false;
    }
    else
    {
    return true;
    }
    });
    </script>


    For more Interesting, Useful Article & codes visit IT New Code.

    Monday 31 October 2016

    How to hide Coupon form in WooCommerce, WordPress?

    In case you're not utilizing coupons by any stretch of the imagination, you can conceal the structure on the truck and checkout page by unchecking "coupons checkbox" from WooCommerce > Settings > General, yet most times you'll need to leave coupons empowered on the off chance that you have to give a client a rebate for reasons unknown.

    Or Can Disable it by adding following code.


    Add following code in "functions.php" file.

    <?php
    // hide coupon form everywhere in woocommerce site
    function hide_coupon_field( $enabled ) {
    if ( is_cart() || is_checkout() ) {
    $enabled = false;
    }

    return $enabled;
    }
    add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field' );
    ?>



    For more Interesting, Useful Article & codes visit IT New Code.

    Woocommerce add to cart button redirect to checkout Learn

    Method 1 for manual link:-

    Try WooCommerce default method for add to cart button redirect to checkout. You can find the option in the WooCommerce -> Settings -> Products -> Display area. When the option “Redirect to the cart page after successful addition” is checked it will redirect all users to the cart after adding a product to the cart.
    Uncheck it.



    Then directly use following code:-
    <a href="/checkout/?add-to-cart=2817&amp;quantity=1">Add to Cart</a>
    2817 is procuct id.
    1 is number of products add in cart.

    Method 2:-

    1. You can find the option in the WooCommerce -> Settings -> Products -> Display area. When the option “Redirect to the cart page after successful addition” is checked it will redirect all users to the cart after adding a product to the cart.
    Uncheck it.



    2. Woocommerce > Settings > Checkout (Tab) - where you should select pages for cart and checkout.
    Selcect Cart Page as Checkout option from drop down menu.


    Just it.
    Now, Add to cart button will redirect to checkout page.


    For more Interesting, Useful Article & codes visit IT New Code.




    Sunday 9 October 2016

    How to change WordPress login page WordPress Logo?

    You can change WordPress login page WordPress logo to website logo using Two methods.

    Method 1:-

    Using Plugin:-
    Customize Login Image:
    https://wordpress.org/plugins/customize-login-image/screenshots/

    WP Custom Admin Login Page Logo:
    https://wordpress.org/plugins/wp-custom-login-page-logo/screenshots/


    Method 2:-

    Using code:-
    First you need to open your theme’s "functions.php" file and then paste the following code:

    <?php
    function custom_loginlogo() {
    echo '<style type="text/css">
    h1 a {background-image: url('.get_bloginfo('template_directory').'/images/login_logo.png) !important; }
    </style>';
    }
    add_action('login_head', 'custom_loginlogo');
    ?>

    put Your website logo behalf of "login_logo.png" logo image.


    For more Interesting, Useful Article & codes visit IT New Code.

    Saturday 8 October 2016

    How to any value display only till 2 decimal points?

    Using following methods can display only 2 decimal point value.
    
    
    Method 1:-
    <?php
     $final_total=199.9;
     
        $formattedNum = number_format($final_total, 2);
        echo $formattedNum;
     ?>
    
    Method 2:- 
     
    <?php 
     $final_total=199.9;
     echo $number = sprintf('%0.2f', $final_total); 
     ?>
     
     
    


    For more Interesting, Useful Article & codes visit IT New Code.

    How to hide other Shipping methods When free Shipping is available in WooCommerce, WordPress?


    Some times there are many methods use for diffident need & conditions in WooCommerce. In it one comman condition is like "Hide other Shipping methods When free Shipping is available". Below is given solution of this condition.

    First create Free Shipping method with condition.Then,

    Add following code in functions.php file


    Snippets for WooCommerce 2.5
    <?php
    /**
     * woocommerce_package_rates is a 2.1+ hook
     */
    add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 );

    /**
     * Hide shipping rates when free shipping is available
     *
     * @param array $rates Array of rates found for the package
     * @param array $package The package array/object being shipped
     * @return array of modified rates
     */
    function hide_shipping_when_free_is_available( $rates, $package ) {
     
      // Only modify rates if free_shipping is present
      if ( isset( $rates['free_shipping'] ) ) {
     
      // To unset a single rate/method, do the following. This example unsets flat_rate shipping
      unset( $rates['flat_rate'] );
     
      // To unset all methods except for free_shipping, do the following
      $free_shipping          = $rates['free_shipping'];
      $rates                  = array();
      $rates['free_shipping'] = $free_shipping;
    }

    return $rates;
    }
    ?>



    Snippets for WooCommerce Version 2.6+
    <?php
    /**
     * Hide shipping rates when free shipping is available.
     * Updated to support WooCommerce 2.6 Shipping Zones.
     *
     * @param array $rates Array of rates found for the package.
     * @return array
     */
    function my_hide_shipping_when_free_is_available( $rates ) {
    $free = array();
    foreach ( $rates as $rate_id => $rate ) {
    if ( 'free_shipping' === $rate->method_id ) {
    $free[ $rate_id ] = $rate;
    break;
    }
    }
    return ! empty( $free ) ? $free : $rates;
    }
    add_filter( 'woocommerce_package_rates', 'my_hide_shipping_when_free_is_available', 100 );
    ?>





    For more Interesting, Useful Article & codes visit IT New Code.


    How to Create Contact form 7 HTML Structure code for send E-mail in WordPress?

    First Create Contact form in contact form 7 Plugin.
    Then Put following code in Mail structure.

    CODE:-

    <div style="width:70%;background: rgba(204, 204, 204, 0.36);padding: 30px;margin: 0 auto;">
    <center><img style="max-height: 100px;" src="Logo_url"></center>
    <center><h2>Inquiry About Site</h2></center>
    <center>
    <table style="background: #DDDDDD;color: #005BC6;width: 90%;">
    <tbody>
    <tr style="line-height: 24px;">
    <td style="padding: 5px 10px;color: #000;font-weight: bold;">Name:</td>
    <td style="padding: 5px 10px;line-height: 17px;">[your-name]</td>
    </tr>

    <tr style="line-height: 24px;">
    <td style="padding: 5px 10px;color: #000;font-weight: bold;">Email:</td>
    <td style="padding: 5px 10px;line-height: 17px;">[your-email]</td>
    </tr>

    <tr style="line-height: 24px;">
    <td style="padding: 5px 10px;color: #000;font-weight: bold;">Contact No:</td>
    <td style="padding: 5px 10px;line-height: 17px;">[tel-no]</td>
    </tr>

    <tr style="line-height: 24px;">
    <td style="padding: 5px 10px;color: #000;font-weight: bold;">Message:</td>
    <td style="padding: 5px 10px;line-height: 17px;">[your-message]</td>
    </tr>

    </tbody>
    </table>
    <center>
    </div>

    <center><small>This email sent from "<a href="#" target="_blank">#</a>".</small></center>

    You can change as your form need.


    For more Interesting, Useful Article & codes visit IT New Code.

    In WordPress if template name is "something" then excecute code?

    Just add following code where you need.


    <?php
    if ( is_page_template('template_file_name.php') ) {
        // Returns true when 'template_file_name.php' is being used.
    } else {
        // Returns false when 'template_file_name.php' is not being used.
    }
    ?>


    For more Interesting, Useful Article & codes visit IT New Code.

    Wednesday 27 July 2016

    How to Rename Coupon Code fields with WooCommerce, WordPress?


    Just renaming the coupon field to something else can likewise diminish the quantity of clients that leave your site amid checkout to discover coupon codes. Clients that as of now have the code will comprehend what name to search for whatever length of time that you're steady. For instance, on the off chance that you email out "Offer Codes" or "Promo Codes", then clients will search for this field, yet those without coupons won't get occupied by the words "coupon" or 'rebate'.

    Simply following the steps of code changing for rename the coupon code fields.

    Add following code in "functions.php" file.


    <?php
    /************************************************
     * rename the coupon field on the cart page
     ************************************************/
    function woocommerce_rename_coupon_field_on_cart( $translated_text, $text, $text_domain ) {
    // bail if not modifying frontend woocommerce text
    if ( is_admin() || 'woocommerce' !== $text_domain ) {
    return $translated_text;
    }
    if ( 'Apply Coupon' === $text ) {
    $translated_text = 'Apply Promo Code';
    }
    return $translated_text;
    }
    add_filter( 'gettext', 'woocommerce_rename_coupon_field_on_cart', 10, 3 );



    /************************************************
     * rename the "Have a Coupon?" message on the checkout page
     ************************************************/
    function woocommerce_rename_coupon_message_on_checkout() {
    return 'Have a Promo Code?' . ' <a href="#" class="showcoupon">' . __( 'Click here to enter your code', 'woocommerce' ) . '</a>';
    }
    add_filter( 'woocommerce_checkout_coupon_message', 'woocommerce_rename_coupon_message_on_checkout' );
    // rename the coupon field on the checkout page
    function woocommerce_rename_coupon_field_on_checkout( $translated_text, $text, $text_domain ) {
    // bail if not modifying frontend woocommerce text
    if ( is_admin() || 'woocommerce' !== $text_domain ) {
    return $translated_text;
    }
    if ( 'Coupon code' === $text ) {
    $translated_text = 'Promo Code';

    } elseif ( 'Apply Coupon' === $text ) {
    $translated_text = 'Apply Promo Code';
    }
    return $translated_text;
    }
    add_filter( 'gettext', 'woocommerce_rename_coupon_field_on_checkout', 10, 3 );

    ?>

    Above bold text place do rename as you need.



    For more Interesting, Useful Article & codes visit IT New Code.

    Saturday 23 July 2016

    Learn about left join query

    The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match.

    In some databases LEFT JOIN is called LEFT OUTER JOIN.

    Query:-

    SELECT column_name(s)
    FROM table1
    LEFT JOIN table2
    ON table1.column_name=table2.column_name;

    OR

    SELECT column_name(s)
    FROM table1
    LEFT OUTER JOIN table2
    ON table1.column_name=table2.column_name;

    Now,Join Query with objects:-

    Query 1 simple
    ------------------
    
    select t.*,c.* from time as t  LEFT JOIN country as c ON t.countryId=c.id 
    Query 2 long 
    ------------------
    select t.*,c.*,st.*,d.* from time as t  LEFT JOIN country as c ON t.countryId=c.id LEFT JOIN  states as st ON t.stateId=st.id LEFT JOIN date as d ON t.dateId=d.id 
    Query 3 in order
    --------------------
    select t.*,c.*,st.*,d.* from time as t  LEFT JOIN country as c ON t.countryId=c.id LEFT JOIN  states as st ON t.stateId=st.id LEFT JOIN date as d ON t.dateId=d.id  ORDER BY name
    Query 4 conditional
    --------------------
    select t.*,c.*,st.*,d.* from time as t  LEFT JOIN country as c ON t.countryId=c.id LEFT JOIN  states as st ON t.stateId=st.id LEFT JOIN date as d ON t.dateId=d.id  ORDER BY name where usr_id=$id



    For more Interesting, Useful Article & codes visit IT New Code.

    Saturday 25 June 2016

    How to Create Custom Plugin?

    Hi, Learn here to create Simple form  Plugin.
    Create 3 files & 1 directory as "images" name.
    1. custom_fields_variable.php
    2. readme.txt
    3. uninstall.php

    1> Here, "images" Directory for Upoad Images like, logo.

    2> "readme.txt" for description about your Plugin.

    3>  Copy following code in "custom_fields_variable.php"  file.
          All details are described in comments.

    <?php
    /**
    * Plugin Name: Custom Fields Variable
    * Plugin URI: #
    * Description: This plugin is create custom fields & its variable. You can print this value to anywhere using variable.
    * Version: 1.0
    * Author: Ankit Shah
    * Author URI: http://itnewcode.blogspot.com/
    * License: GPL
    */
    ?>
    <?php
    /*
    we’ll do is create a menu entry in the backend where we can place our settings user interface:
    add_menu_page() function arguments:
    1. Page title – used in the title tag of the page (shown in the browser bar) when it is displayed.
    2. Menu title – used in the menu on the left.
    3. Capability – the user level allowed to access the page.
    4. Menu slug – the slug used for the page in the URL.
    5. Function – the name of the function you will be using to output the content of the page.
    6. Icon – A url to an image or a Dashicons string.
    7. Position – The position of your item within the whole menu.
    */

    // create custom plugin settings menu
    add_action('admin_menu', 'custom_fields_variable_plugin_create_menu');

    function custom_fields_variable_plugin_create_menu() {

    //create new top-level menu
    add_menu_page('Custom Fields Variable Plugin Settings', 'CFV Settings', 'administrator', __FILE__, 'custom_fields_variable_plugin_settings_page' , plugins_url('/images/icon.png', __FILE__) );

    //call register settings function
    add_action( 'admin_init', 'register_custom_fields_variable_plugin_settings' );
    }


    function register_custom_fields_variable_plugin_settings() {
    //register our settings
    register_setting( 'cfv-plugin-settings-group', 'header_logo' );  // For file upload
    register_setting( 'cfv-plugin-settings-group', 'aks_name' );
    register_setting( 'cfv-plugin-settings-group', 'aks_textarea' );
    register_setting( 'cfv-plugin-settings-group', 'aks_radio' );
    register_setting( 'cfv-plugin-settings-group', 'aks_checkbox1' );
    register_setting( 'cfv-plugin-settings-group', 'aks_checkbox2' );
    register_setting( 'cfv-plugin-settings-group', 'aks_color' );
    register_setting( 'cfv-plugin-settings-group', 'aks_email' );
    register_setting( 'cfv-plugin-settings-group', 'aks_number' );
    register_setting( 'cfv-plugin-settings-group', 'aks_tel' );
    register_setting( 'cfv-plugin-settings-group', 'aks_time' );
    register_setting( 'cfv-plugin-settings-group', 'aks_url' );
    register_setting( 'cfv-plugin-settings-group', 'aks_week' );
    register_setting( 'cfv-plugin-settings-group', 'aks_month' );
    register_setting( 'cfv-plugin-settings-group', 'aks_date' );
    }

    function custom_fields_variable_plugin_settings_page() {
    ?>
    <div class="wrap">
    <h2>Your Plugin Name</h2>

    <form method="post" action="options.php">
        <?php settings_fields( 'cfv-plugin-settings-group' ); ?>
        <?php do_settings_sections( 'cfv-plugin-settings-group' ); ?>
    <?php
    //Upload file Code START
    ?>
    <?php
    if(function_exists( 'wp_enqueue_media' )){
        wp_enqueue_media();
    }else{
        wp_enqueue_style('thickbox');
        wp_enqueue_script('media-upload');
        wp_enqueue_script('thickbox');
    }
    ?>
    <p><strong>Header Logo Image URL:</strong><br />
                    <img class="header_logo" src="<?php echo get_option('header_logo'); ?>" height="100" width="100"/>
                    <input class="header_logo_url" type="text" name="header_logo" size="60" value="<?php echo get_option('header_logo'); ?>">
                    <a href="#" class="header_logo_upload">Upload</a>
    </p>  

    <script>
        jQuery(document).ready(function($) {
            $('.header_logo_upload').click(function(e) {
                e.preventDefault();

                var custom_uploader = wp.media({
                    title: 'Custom Image',
                    button: {
                        text: 'Upload Image'
                    },
                    multiple: false  // Set this to true to allow multiple files to be selected
                })
                .on('select', function() {
                    var attachment = custom_uploader.state().get('selection').first().toJSON();
                    $('.header_logo').attr('src', attachment.url);
                    $('.header_logo_url').val(attachment.url);

                })
                .open();
            });
        });
    </script>
    <?php
    //Upload file Code END
    ?>
        <table class="form-table">
    <tr valign="top">
            <th scope="row">Name:</th>
            <td><input type="text" name="aks_name" value="<?php echo esc_attr( get_option('aks_name') ); ?>" /></td>
            </tr>

    <tr valign="top">
            <th scope="row">Textarea:</th>
            <td><textarea name="aks_textarea" rows="3" cols="50"><?php echo esc_attr( get_option('aks_textarea') ); ?></textarea></td>
            </tr>

    <tr valign="top">
            <th scope="row">Radio:</th>
            <td><input type="radio" name="aks_radio" value="Male" <?php if ( Male == esc_attr( get_option('aks_radio') ) ) echo 'checked="checked"'; ?> />Male
    <input type="radio" name="aks_radio" value="Female" <?php if ( Female == esc_attr( get_option('aks_radio') ) ) echo 'checked="checked"'; ?> />Female
    </td>
            </tr>

    <tr valign="top">
            <th scope="row">checkbox:</th>
            <td><input type="checkbox" name="aks_checkbox1" value="checkbox1" <?php if ( checkbox1 == esc_attr( get_option('aks_checkbox1') ) ) echo 'checked="checked"'; ?> />Male
    <input type="checkbox" name="aks_checkbox2" value="checkbox2" <?php if ( checkbox2 == esc_attr( get_option('aks_checkbox2') ) ) echo 'checked="checked"'; ?> />Female
    </td>
            </tr>

    <tr valign="top">
            <th scope="row">Color:</th>
            <td><input type="color" name="aks_color" value="<?php echo esc_attr( get_option('aks_color') ); ?>" /></td>
            </tr>

    <tr valign="top">
            <th scope="row">E-mail:</th>
            <td><input type="email" name="aks_email" value="<?php echo esc_attr( get_option('aks_email') ); ?>" /></td>
            </tr>

    <tr valign="top">
            <th scope="row">Telephone Number:</th>
            <td><input type="number" name="aks_number" value="<?php echo esc_attr( get_option('aks_number') ); ?>" /></td>
            </tr>

    <tr valign="top">
            <th scope="row">Mobile Number:</th>
            <td><input type="tel" name="aks_tel" value="<?php echo esc_attr( get_option('aks_tel') ); ?>" /></td>
            </tr>

    <tr valign="top">
            <th scope="row">Time:</th>
            <td><input type="time" name="aks_time" value="<?php echo esc_attr( get_option('aks_time') ); ?>" /></td>
            </tr>

    <tr valign="top">
            <th scope="row">URL:</th>
            <td><input type="url" name="aks_url" value="<?php echo esc_attr( get_option('aks_url') ); ?>" /></td>
            </tr>

    <tr valign="top">
            <th scope="row">Week:</th>
            <td><input type="week" name="aks_week" value="<?php echo esc_attr( get_option('aks_week') ); ?>" /></td>
            </tr>

    <tr valign="top">
            <th scope="row">Month:</th>
            <td><input type="month" name="aks_month" value="<?php echo esc_attr( get_option('aks_month') ); ?>" /></td>
            </tr>

    <tr valign="top">
            <th scope="row">Date:</th>
            <td><input type="date" name="aks_date" value="<?php echo esc_attr( get_option('aks_date') ); ?>" /></td>
            </tr>

        </table>
        <?php submit_button(); ?>
    </form>
    </div>
    <?php } ?>
    <?php
    /*
    To Print specific value of This fields paste following code:
    $aks_name = get_option( 'aks_name' );
         print_r($aks_name);


    //for full data loop Example:
    global $wpdb;
    $table_name = $wpdb->prefix . 'options';
    $results = $wpdb->get_results ("SELECT * FROM $table_name;");
    //print_r($results);
    echo '<select>';
    foreach ( $results as $result ) {
        echo '<option>'.$result->option_name.'</option>';
    }
    echo '</select>';

    */
    ?>
    <?php
    add_action( 'wp_head', 'api_ids' );
    /*for check this code is working or not print variable & check inspect element to <head> tag.
    This variable can any where in code beacuse of it is global variable  */

    function api_ids() {

    global $header_logo;
    $header_logo = get_option( 'header_logo' );
    // print_r($header_logo);

    global $aks_name;
    $aks_name = get_option( 'aks_name' );
    // print_r($aks_name);

    global $aks_textarea;
    $aks_textarea = get_option( 'aks_textarea' );
    // print_r($aks_textarea);

    global $aks_radio;
    $aks_radio = get_option( 'aks_radio' );
    // print_r($aks_radio);

    global $aks_checkbox1;
    $aks_checkbox1 = get_option( 'aks_checkbox1' );
    // print_r($aks_checkbox1);

    global $aks_checkbox2;
    $aks_checkbox2 = get_option( 'aks_checkbox2' );
    // print_r($aks_checkbox2);

    global $aks_color;
    $aks_color = get_option( 'aks_color' );
    // print_r($aks_color);

    global $aks_email;
    $aks_email = get_option( 'aks_email' );
    // print_r($aks_email);

    global $aks_number;
    $aks_number = get_option( 'aks_number' );
    // print_r($aks_number);

    global $aks_tel;
    $aks_tel = get_option( 'aks_tel' );
    // print_r($aks_tel);

    global $aks_time;
    $aks_time = get_option( 'aks_time' );
    // print_r($aks_time);

    global $aks_url;
    $aks_url = get_option( 'aks_url' );
    // print_r($aks_url);

    global $aks_week;
    $aks_week = get_option( 'aks_week' );
    // print_r($aks_week);

    global $aks_month;
    $aks_month = get_option( 'aks_month' );
    // print_r($aks_month);

    global $aks_date;
    $aks_date = get_option( 'aks_date' );
    // print_r($aks_date);

    /*
    Now You can print this variable any where like:
    echo $header_logo;
    echo $aks_name;
    echo $aks_textarea;
    echo $aks_radio;
    echo $aks_checkbox1;
    echo $aks_checkbox2;
    echo $aks_color;
    echo $aks_email;
    echo $aks_number;
    echo $aks_tel;
    echo $aks_time;
    echo $aks_url;
    echo $aks_week;
    echo $aks_month;
    echo $aks_date;
    */
    }



    /*
    If plugin active then & only then code execute.
    first argument is for path,
    Seconf argument is function.
    */
    register_activation_hook( __FILE__, 'api_ids' );



    /*
    If plugin deactive remove code of plugin.
    first argument is for path,
    Seconf argument is function.
    here no function defined.

    Example:
    register_deactivation_hook( __FILE__, 'deactive function' );
    */


    /*
    You can use for uninstall register_uninstall_hook() function or "uninstall.php" page.
    we created "uninstall.php" page.
    If plugin uninstall all data remove.
    first argument is for path,
    Seconf argument is function.

    Example:
    register_uninstall_hook( __FILE__, 'uninstall_plugin_function' );
    function uninstall_plugin_function() {
      // Uninstallation code comes here
            // If uninstall is not called from WordPress, exit
    if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    exit();
    }

    //all register_setting() function add here & delete it
    $header_logo = 'header_logo';
    $aks_name = 'aks_name';
    $aks_textarea = 'aks_textarea';
    $aks_radio = 'aks_radio';
    $aks_checkbox1 = 'aks_checkbox1';
    $aks_checkbox2 = 'aks_checkbox2';
    $aks_color = 'aks_color';
    $aks_email = 'aks_email';
    $aks_number = 'aks_number';
    $aks_tel = 'aks_tel';
    $aks_time = 'aks_time';
    $aks_url = 'aks_url';
    $aks_week = 'aks_week';
    $aks_month = 'aks_month';
    $aks_date = 'aks_date';


    delete_option($header_logo);
    delete_option($aks_name);
    delete_option($aks_textarea);
    delete_option($aks_radio);
    delete_option($aks_checkbox1);
    delete_option($aks_checkbox2);
    delete_option($aks_color);
    delete_option($aks_email);
    delete_option($aks_number);
    delete_option($aks_tel);
    delete_option($aks_time);
    delete_option($aks_url);
    delete_option($aks_week);
    delete_option($aks_month);
    delete_option($aks_date);
    }
    */

    ?>


    4> Copy following code in "uninstall.php" file.
         This code will execute when delete or uninstall that plugin.

    <?php

    // If uninstall is not called from WordPress, exit
    if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
        exit();
    }

    /*
    all register_setting() function add here & delete it
    */
    $header_logo = 'header_logo';
    $aks_name = 'aks_name';
    $aks_textarea = 'aks_textarea';
    $aks_radio = 'aks_radio';
    $aks_checkbox1 = 'aks_checkbox1';
    $aks_checkbox2 = 'aks_checkbox2';
    $aks_color = 'aks_color';
    $aks_email = 'aks_email';
    $aks_number = 'aks_number';
    $aks_tel = 'aks_tel';
    $aks_time = 'aks_time';
    $aks_url = 'aks_url';
    $aks_week = 'aks_week';
    $aks_month = 'aks_month';
    $aks_date = 'aks_date';




    delete_option($header_logo);
    delete_option($aks_name);
    delete_option($aks_textarea);
    delete_option($aks_radio);
    delete_option($aks_checkbox1);
    delete_option($aks_checkbox2);
    delete_option($aks_color);
    delete_option($aks_email);
    delete_option($aks_number);
    delete_option($aks_tel);
    delete_option($aks_time);
    delete_option($aks_url);
    delete_option($aks_week);
    delete_option($aks_month);
    delete_option($aks_date);



    /*
    // Drop a custom db table if you created a table
    global $wpdb;
    $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}tablename" );
    */
    ?>




    Click here to Download This Plugin.

    For more Interesting, Useful Article & codes visit IT New Code.

    Friday 24 June 2016

    Learn Various Anchor tag Usage.

    The <a> Anchor tag use for the hyperlink, Always <a> Anchor tag is use for link one page to another page or Same page jump to selected div or section.

    The most important attribute of <a> tag is the "href", which is used for destination link.
    Another attribute is "target", Use for where to open the linked document.
    There are 4 values available for it _blank, _parent, _self & _top.

    By default, <a> anchor tag will appear as follows:

    Unvisited link looks as underlined and blue color,
    Visited link looks as underlined and purple color,
    & Active link looks as underlined and red color.

    Style for <a> Anchor tag:
    <style>
    a {color:blue;}
    a:link    {color:green;}
    a:visited {color:pink;}
    a:hover   {color:red;}
    a:active  {color:yellow;}
    </style>


    Example:-
    <a href="http://itnewcode.blogspot.in/" target="_blank">IT New Code</a>
    here,
    href for Url or Path locaction

    target for where to open the linked document it may be 4 types(_blank, _parent, _self, _top)



    Skype link:-
    <a href="skype:skaype_name?call">Skype name</a>
    **************************************************************

    Call link:-
    <a href="tel:3177594940">317.759.4940</a>
    **************************************************************

    Mail link:-
    <a href="mailto:test@gmail.com">test@gmail.com</a>
    **************************************************************

    Mail with subject link:-
    <a href="mailto:test@gmail.com?Subject=Your Subject">test@gmail.com</a>
    **************************************************************

    Gmail email link:-
    <a href="mailto:http://mail.google.com/mail/?view=cm&fs=1&tf=1&to=test@gmail.com&su=Your Subject">test@gmail.com</a>
    **************************************************************

    Vimeo embed code:-
    <div class="video-holder">&nbsp;<iframe src="http://player.vimeo.com/video/#####"  
    width="561" height="316" frameborder="0" webkitAllowFullScreen mozallowfullscreen
    allowFullScreen></iframe></p>
    **************************************************************

    You Tube embed code:-
    <iframe title="YouTube video player" class="youtube-player" type="text/html"
    width="640" height="390" src="http://www.youtube.com/embed/##########"
    frameborder="0" allowFullScreen></iframe>
    **************************************************************

    Open Multiple windows link on single click:-
    <a href="https://www.facebook.com/" target="_blank" onclick="window.open('http://www.google.com/'); window.open('http://www.yahoo.com/');">Single Click Open Multiple windows link</a>
    **************************************************************

    Map Anchor tag:-
    <a class="to-map" href="https://maps.google.com/?q=loc:-43.6298474,172.7269425">13 Hunters Rd, Diamond Harbour 8971, New Zealand</a>

    Here,
    -43.6298474 is latitude and
    172.7269425 is logitude.
    **************************************************************

    Map Embed & Anchor tag:-
    <iframe src = "https://maps.google.com/maps?q=10.305385,77.923029&hl=es;z=14&amp;output=embed"></iframe>
    <a href="https://maps.google.com/maps?q=10.305385,77.923029&hl=es;z=14&amp;output=embed" style="color:#0000FF;text-align:left" target="_blank">See map bigger</a>

    Here,
    -10.305385 is latitude and
    77.923029 is logitude.
    "es" is spanish language and "z" is the zoom that will have the map.
    **************************************************************

    Google Calendar Add to your account Or Subscribe code:-
    <a href="http://www.google.com/calendar/render?cid=[CALENDAR-XML-LINK]" target="_blank"><img border="0" src="//www.google.com/calendar/images/ext/gc_button6.gif"></a>

    Example:
    <a href="http://www.google.com/calendar/render?cid=http%3A%2F%2Fwww.google.com%2Fcalendar%2Ffeeds%2Fsstx.org_siq5ectrvg921eipq0qdu5fho4%2540group.calendar.google.com%2Fpublic%2Fbasic" target="_blank"><img border="0" src="//www.google.com/calendar/images/ext/gc_button6.gif"></a>
    **************************************************************

    Pass Variable data in Php Anchor Tag:-
    <?php $id=10; ?>
    <a class='link' href=\"Adminupdateotherprofile.php?id=$id\">VIEW & EDIT</a>
    & receive it as following
    <?php echo $_GET['id']; ?>
    **************************************************************

    Countdown Timer:-
    https://www.timeanddate.com/clocks/freecountdown.html
    https://countingdownto.com/countdown-widgets/edit/event-name-countdown-clock-0b98cd98-de66-4280-b9d2-1abf6a111087
    **************************************************************

    API Create (Social Network Integrations):-
    Facebook, Google+, Instagram, PayPal, Twitter, LinkedIn, Amazon, Yahoo, Windows Live, Tumblr, BufferApp, Foursquare, VK.com
    http://wpweb.co.in/documents/social-network-integration/
    **************************************************************

    For more Interesting, Useful Article & codes visit IT New Code.

    How to Fetch Data from Database of all users in table structre, Open Each user profile & Update it? How to Get Value By passing Variable as id?

    Create three files & 1 directory create called "upload".
    1. alluserfetchdata.php
    2. Adminupdateotherprofile.php
    3. Adminupdateotherprofileprocess.php

    1> Copy Following code in "alluserfetchdata.php" file.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Fetch data</title>
    </head>

    <body>
    <table width="200" border="1">
     <tr>
    <th>No</th>
    <th>name</th>
    <th>gender</th>
    <th>Discription</th>
    <th>View</th>
     </tr>

    <?php

     $con=mysql_connect('localhost','root','');
    if(!$con)
    {
    echo "Connection error".mysql_error();
    }
    $db=mysql_select_db('test1');
    $sql="select * from registration";
    echo $sql;
    $i=1;
    $result=mysql_query($sql,$con);
    while($row=mysql_fetch_array($result))
    {
    $id=$row['id'];

    echo "<tr>";

    echo "<td>".$i."</td>";
    echo "<td>".$row['name']."</td>";
    echo "<td>".$row['gender']."</td>";
    echo "<td>".$row['discreption']."</td>";
    echo "<td><a class='link' href=\"Adminupdateotherprofile.php?id=$id\">VIEW & EDIT</a></td>";
    echo "</tr>";
    $i++;
    }
    ?>
    </table>

    </body>
    </html>


    2> Copy Following code in "Adminupdateotherprofile.php" file.
          Here,We Get data by passing id as variable & get all that Id Data.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Selected person data</title>
    <style>
    input[type=text]{color:#0F3; width:300px; outline:red;}
    </style>
    </head>

    <body>
    <?php
    //session_start();
    //$id=$_SESSION['id'];
    //echo $_SESSION['id'];
    $con=mysql_connect('localhost','root','');
    if(!$con)
    {
    echo "Connection error".mysql_error();
    }
    $db=mysql_select_db('test1');
    $sql="select * from registration where id=".$_GET['id'];
    //echo $sql;
    $result=mysql_query($sql,$con);
    while($row=mysql_fetch_array($result))
    {
    ?>
    <form method="post" action="Adminupdateotherprofileprocess.php" enctype="multipart/form-data">
    <table width="200" border="1">
    <input type="hidden" name="id" value="<?php echo $row['id']; ?>" />
     <tr>
    <td>Name:</td>
    <td><input type="text" name="name" value="<?php echo $row['name']; ?>"/></td>
     </tr>
     <tr>
    <td>Gender:</td>
    <td><input type="radio" name="gender" value="<?php echo $row['gender']; ?>" checked="checked"/><?php echo $row['gender']; ?>
    <?php
    if($row['gender']=='Male')
    {?>
    <input type="radio" name="gender" value="Female"/>Female
    <?php
    }
    else
    {?>
    <input type="radio" name="gender" value="Male"/>Male
    <?php
    }
    ?></td>
     </tr>
     <tr>
    <td>discription</td>
    <td><textarea name="discreption" ><?php echo $row['discreption']; ?></textarea></td>
     </tr>
     <tr>
    <td>Photo:</td>
    <td><input type="file" name="photo" value="<?php echo $row['photo']; ?>" required="required"/></td>
     </tr>
     <tr>
    <td>Image:</td>
    <td><img src="<?php echo $row['photo']; ?>" width="300px" height="300px"/></td>
     </tr>
    </table>
    <input type="submit" name="update" value="UPDATE" />
    </form>
    <?php
    }
    ?>

    </body>
    </html>

     

    3> Copy Following code in "Adminupdateotherprofileprocess.php" file.
         UPDATE profile here.
    <?php
    session_start();
    $id=$_POST['id'];
    $name=$_POST['name'];
    $gender=$_POST['gender'];
    //$photo=$_POST['photo'];
    $discreption=$_POST['discreption'];


    $dir="upload/";
    $path=$dir.basename($_FILES['photo']['name']);
    move_uploaded_file($_FILES['photo']['tmp_name'],$path);

    //$id=$_SESSION['id'];

    $con=mysql_connect('localhost','root','');
    if(!$con)
    {
    echo "Connection error".mysql_error();
    }
    $db=mysql_select_db('test1');
    $sql="UPDATE `registration` SET `name`='$name',`gender`='$gender',`photo`='$path',`discreption`='$discreption' WHERE id='$id'";
    echo $sql;
    $result=mysql_query($sql,$con);
    if($result>0)
    {
    echo "Successfull";
    }
    else
    {
    echo "fail";
    }


    To download code Click Here.

    For more Interesting, Useful Article & codes visit IT New Code.

    How to Fetch Data from Database as Single person Profile & update Profile data?

    Create two files &  1 directory create called "upload".
    1. profile.php
    2. profileupdateprocess.php


    1> Copy Following code in "profile.php" file.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Profile (Fetch data)</title>
    </head>

    <body>
    <?php
    session_start();
    $id=$_SESSION['id'];
    //echo $_SESSION['id'];
    $con=mysql_connect('localhost','root','');
    if(!$con)
    {
    echo "Connection error".mysql_error();
    }
    $db=mysql_select_db('test1');
    $sql="select * from registration where id='$id'";
    //echo $sql;
    $result=mysql_query($sql,$con);
    while($row=mysql_fetch_array($result))
    {
        ?>
        <form method="post" action="profileupdateprocess.php" enctype="multipart/form-data">
    <table width="200" border="1">
      <tr>
        <td>Name:</td>
        <td><input type="text" name="name" value="<?php echo $row['name']; ?>"/></td>
      </tr>
      <tr>
        <td>Gender:</td>
        <td><input type="radio" name="gender" value="<?php echo $row['gender']; ?>" checked="checked"/><?php echo $row['gender']; ?>
    <?php
        if($row['gender']=='Male')
        {?>
    <input type="radio" name="gender" value="Female"/>Female
        <?php
    }
        else
        {?>
    <input type="radio" name="gender" value="Male"/>Male
        <?php
    }
    ?></td>
      </tr>
      <tr>
        <td>discription</td>
        <td><textarea name="discreption" ><?php echo $row['discreption']; ?></textarea></td>
      </tr>
      <tr>
        <td>Photo:</td>
        <td><input type="file" name="photo" value="<?php echo $row['photo']; ?>" required="required"/></td>
      </tr>
      <tr>
        <td>Image:</td>
        <td><img src="<?php echo $row['photo']; ?>" width="300px" height="300px"/></td>
      </tr>
    </table>
    <input type="submit" name="update" value="UPDATE" />
    </form>
    <?php
    }
    ?>
    </body>
    </html>


    2> Copy Following code in "profileupdateprocess.php" file.
    <?php
    session_start();
    $name=$_POST['name'];
    $gender=$_POST['gender'];
    //$photo=$_POST['photo'];
    $discreption=$_POST['discreption'];


    $dir="upload/";
    $path=$dir.basename($_FILES['photo']['name']);
    move_uploaded_file($_FILES['photo']['tmp_name'],$path);

    $id=$_SESSION['id'];

    $con=mysql_connect('localhost','root','');
    if(!$con)
    {
    echo "Connection error".mysql_error();
    }
    $db=mysql_select_db('test1');
    $sql="UPDATE `registration` SET `name`='$name',`gender`='$gender',`photo`='$path',`discreption`='$discreption' WHERE id='$id'";
    echo $sql;
    $result=mysql_query($sql,$con);
    if($result>0)
    {
    echo "Successfull";
    }
    else
    {
    echo "fail";
    }



    To download code Click Here.

    For more Interesting, Useful Article & codes visit IT New Code.

     

    Copyright @ 2016 IT New Code | Developing Code | Designing Code.

    Designed by: Ankit Shah