Tuesday, November 18, 2014

How to detect the width of a web browser using jQuery?

Detecting the width of a browser window can be very useful when designing a website, it allows you to create a more responsive design which is suited to the current browser dimensions.
Using the small chunk of jQuery below, you can easily detect the current width of a web browser & perform various actions when the width reaches a particular range of values. When redeveloping my site I opted to use this method to add a different body class to the site when the browser width reaches a below particular points: "smaller" when the width reaches below 960px but greater than 400px and "smallest" when the width is below "400px". The additional body classes then allowed me to alter the position/style of particular elements on the page.


(function($){
  //detect the width on page load
  $(document).ready(function(){
    var current_width = $(window).width();
     //do something with the width value here!
    if(current_width < 400){
      jQuery('body').addClass("probably-mobile");
    }
  });

  //update the width value when the browser is resized (useful for devices which switch from portrait to landscape)
  $(window).resize(function(){
    var current_width = $(window).width();
   //do something with the width value here!
    if(current_width < 400){
      jQuery('body').addClass("probably-mobile");
    }
  });

})(jQuery); 

Tuesday, November 11, 2014

How to install Laravel 4 on wamp server?

First thing which you need to check before starting the setup:

Check whether you have the latest version of the php(5.5)

After that you need to download the setup from the link below:

https://getcomposer.org/

Run the setup and install the composer which will download the Laravel 4 files on your server.

After the completion of the setup -> open cmd(Command Promt).

write composer and press enter.

then change the directory to your server directory.

like in my case it was:

c:\user\home> cd c:\wamp\www

this is the comand to be written in cmd.

then your cmd directory would be like this:

c:\wamp\www>

now write the command for installing the Laravel 4.

which is:

composer create-project laravel\laravel yourfoldername --prefer-dist

in cmd it will be as

c:\wamp\www>composer create-project laravel/laravel yourfoldername --prefer-dist

by writing this command an directory with name yourfoldername will be creater in wamp/www.

Thursday, October 30, 2014

How to create an databse in wordpress plugin?

register_activation_hook( __FILE__, 'jal_install' );
register_activation_hook( __FILE__, 'jal_install_data' );


function jal_install() {
    global $wpdb;
    global $jal_db_version;

    $table_name = $wpdb->prefix . 'liveshoutbox';
   
    /*
     * We'll set the default character set and collation for this table.
     * If we don't do this, some characters could end up being converted
     * to just ?'s when saved in our table.
     */
    $charset_collate = '';

    if ( ! empty( $wpdb->charset ) ) {
      $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
    }

    if ( ! empty( $wpdb->collate ) ) {
      $charset_collate .= " COLLATE {$wpdb->collate}";
    }

    $sql = "CREATE TABLE name (
        id mediumint(9) NOT NULL AUTO_INCREMENT,
        time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
        name tinytext NOT NULL,
        text text NOT NULL,
        url varchar(55) DEFAULT '' NOT NULL,
        UNIQUE KEY id (id)
    ) $charset_collate;";

    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta( $sql );

    add_option( 'jal_db_version', $jal_db_version );
}

Wednesday, October 29, 2014

How to include your css in wordpress plugin?

// register jquery and style on initialization


add_action('init', 'register_script');
function register_script() {
    wp_register_script( 'custom_jquery', plugins_url('plug/js/jquery.js'));

    wp_register_style( 'new_style', plugins_url('plug/css/style.css'));
}

// use the registered jquery and style above
add_action('wp_enqueue_scripts', 'enqueue_style');

function enqueue_style(){
   wp_enqueue_script('custom_jquery');

   wp_enqueue_style( 'new_style' );
}





//Link your CSS

<style type="text/css">
<?php include('css/style.css'); ?>
</style>

Tuesday, October 21, 2014

Autorefresh and redirect in html

<META http-equiv="refresh" content="5;URL=www.facebook.com/crazy.snamit"

Here the content means the timesolt in seconds i.e. the time after the page will refresh and move to the url you have set.

Feel Free to comment!!!

Saturday, October 11, 2014

How to get the facebbok page badges in blogger?

To add profile badge to your blogger website you can follow these steps

1) create your profile badge on the link :-
                                       
                                        www.facebook.com/badges

2) Right click on the badge image and click "open image in new tab "

3) Copy the URL of the image

4) Go blogger, choose layout and the "add a widget"

5) Choose "image" widget

6) Write the title like "about us or facebook".

7) Paste badge image which you have copied.

8) Click save.

9) And after watching preview click "save arrangement"

Monday, September 29, 2014

How to remove watermark in wonderplugin slider in wordpress?



Watermark is a link which appears on the plugin as a company link. Which Can be removed only buy purchasing as said buy the publisher.

But here is a trick which could help you out a little.

Here goes the steps.



 inside sliderengine folder open amazingslider.js file with any editor and search for this 


And then search for


Line no. 300 there will a variable wpocss and infront of it there will be written 

display:block !important;

Change it to:-

display:none !important;
Also See How to remove watermark in amazing slider link is given bellow:-



4. If the above method don't work you can use the inspect element tool to get the class or id for it.

5. And edit the script by finding the code according to it.

6. I am also having the whole script with no watermark  which will be provided on request.

Saturday, September 20, 2014

Wordpress tags

Get the site sitle:-

<?php bloginfo('title'); ?>

Get the style sheet linked:-

<?php bloginfo('stylesheet_url');?>

For any other head content:-

<?php wp_head(); ?>

To get the name of the site:-

<?php bloginfo('name'); ?> 

 To get discription of the site:-

<?php bloginfo('name'); ?>

To get the navigation bar:-

<?php wp_nav_menu(); ?>

To get the header file:-

<?php get_header(); ?>

To get the footer file:-

<?php get_footer(); ?>

To get the sidebar:-

<?php get_sidebar(); ?>

To get the Posts:-

<?php while(have_posts()) : the_post(); ?>
       <?php the_title(); ?>/* To get the title of the post */
       <?php the_content(); ?>/* To get the conent of the post */
<?php endwhile; ?>

To get the image:-

Paste the code where u want to show the image:-
 
<?php the_post_thumbnail('full'); ?>

Paste the code to active an feature image in Functions.php file:-

<?php add_theme_support('post-thumbnails'); ?>

To get the author link:-

<?php the_author_posts_link(); ?>

To get the date:-

<?php the_time('F jS, Y'); ?>

For comments:-

<?php comments_link();?>/*Gives an link to comment page.*/

<?php comments_number('0 comment','1 comment','% responses'); ?>
/*
 0 comment : used for no comment.
1 comment : used for 1 comment.
% responses : used for More than 1 coments */

To link a text to dynamic permalink:-

<?php the_permalink(); ?>

To get the comment box:-

<?php comments_template(); ?>


Wednesday, September 17, 2014

Adding a WowSlider Slideshow to your Widget Area

You’ll need to install a plug-in that allows you to write PHP in a text widget.

I used PHP Code Widget

And you can simply add the shortcode in this format:

<?php wowslider(21); ?>


The no 21 will be different for your slider.

Tuesday, September 16, 2014

How to add content in widget area?

To add content into your widget area just use the plugin link below:

https://wordpress.org/plugins/content-widget/

How to limit the no of posts in wordpress?

The below code would help you to limit the no of posts:-

<?php
$page_num = $paged;
if ($pagenum='') $pagenum =1;
query_posts('showposts=4&paged='.$page_num); ?>
<?php if ( have_posts() ) : ?>

            <?php /* Start the Loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>
               
                <?php //the_title();
                ?><div id="read">
                <?php the_content();//get_template_part( 'content', get_post_format() ); ?>
            </div><?php endwhile; ?>

            <?php //twentytwelve_content_nav( 'nav-below' ); ?>

        <?php endif; ?>

How to get the content in an coustom page template?

 
Add the below code in your custom template page:- 
 
 
<?php
/*
Template Name: Archives with Content
*/

get_header(); ?>
<div id="content" class="widecolumn">
    <?php if (have_posts()) : while (have_posts()) : the_post();?>
    <div class="post">
        <h2 id="post-<?php the_ID(); ?>"><?php the_title();?></h2>
        <div class="entrytext">
            <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>
        </div>
    </div>
    <?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>
<div id="main">
    <?php get_search_form(); ?>
    <h2>Archives by Month:</h2>
    <ul>
        <?php wp_get_archives('type=monthly'); ?>
    </ul>   
    <h2>Archives by Subject:</h2>
    <ul>
        <?php wp_list_categories(); ?>
    </ul>
</div>
<?php get_footer(); ?>

Creating a WordPress Theme from Static HTML: Adding Navigation

To complete this tutorial, you will need the following:
  • your code editor of choice
  • a browser for testing your work
  • a WordPress installation, either local or remote
  • If you're working locally, you'll need MAMP, WAMP or LAMP to enable WordPress to run.
  • If you're working remotely, you'll need FTP access to your site plus an administrator account in your WordPress installation.

To register a navigation menu, you use the register_nav_menu() function, which you will need to add to your theme's functions.php file.
As your theme doesn't have this file yet, you start by creating one.
In your theme folder, create a new blank file called functions.php.
Open the new file and add the following to it:
1
2
3
4
5
6
<?php
function wptutsplus_register_theme_menu() {
    register_nav_menu( 'primary', 'Main Navigation Menu' );
}
add_action( 'init', 'wptutsplus_register_theme_menu' );
?>
You've just created your theme's first function, pat yourself on the back!


You'll now have access to the 'Menus' dashboard screen, which wasn't available before as your theme didn't have a menu registered. Right now, its contents aren't perfect but we'll soon change that.


Right now, this menu still won't be visible on your website; you need to add the menu to your header file to make this happen.

Add the code below to header.php:-

<nav class="menu main">
    <?php /*  Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?>
    <div class="skip-link screen-reader-text">
        <a title="Skip to content" href="#content">Skip to content</a>
    </div>
    <?php wp_nav_menu( array( 'container_class' => 'main-nav', 'theme_location' => 'primary' ) ); ?>
</nav><!-- .main -->

Friday, August 29, 2014

How to remove "Private" text from private posts?

function the_title_trim($title) {
$title = attribute_escape($title);
$findthese = array(
'#Protected:#',
'#Private:#'
);
$replacewith = array(
'', // What to replace "Protected:" with
'' // What to replace "Private:" with
);
$title = preg_replace($findthese, $replacewith, $title);
return $title;
}
add_filter('the_title', 'the_title_trim');

Monday, August 25, 2014

How to use custom font in wordpress?

Using non-standard fonts inside WordPress requires two additional steps:
  1. downloading and installing the font
  2. calling the font using @font-face


The CSS selector @font-face allows you to add support for custom fonts by including the font file in your CSS file. To add custom support for nearly any custom font, type the following into your site’s main style.css file:

 
 
 
@font-face{
font-family:karate;
src:url('/www/wp-content/themes/thesis-bp-child/custom-1/fonts/Karate.ttf') format ("truetype");
}


Simply input the name of the new font you’ve uploaded within the font-family selector like this:
 
 
 
#site-title a {font-family:karate;}

How to create an custom page Template?

To create a custom page template make a new file starting with a Template Name inside a PHP comment.

Here's the syntax:

<?php
/*
Template Name: My Custom Page
*/
 ?>
 
Once you upload the file to your Theme's folder, 
the template name, "My Custom Page", will list in the Edit Page screen's Template dropdown. 

Saturday, August 23, 2014

How to create an child theme?

In this example, we’re going to create a child theme for the Twenty Thirteen default WordPress theme.
(These steps can be done for any theme available on internet or if you create a custom them.)

1. The first thing we need to do is create a new folder in our themes directory to hold the child theme.

The themes directory is wp-content/themes for local users i.e. using wamp or xampp(You can do with using cPanel or via FTP for online sites). 

It’s important to name the folder without any space in the name, and it’s common practive to use the name of the parent theme folder with -child added on the end.

So for this example, we’ll be calling our folder “twentythirteen-child”.

2. In the child theme folder, create a file called style.css. This is the only file required to make a child theme.

The style sheet must start with the following lines:

/*
Theme Name: Twenty Thirteen Child
Theme URI: http://wordpress.org/themes/twentythirteen
Description: Twenty Thirteen Child Theme
Author: WPMU
Author URI: http://wpmu.com
Template: twentythirteen
Version: 1.0.0
*/
@import url("../twentythirteen/style.css");
/* =Theme customization starts here
-------------------------------------------------------------- */

Disable Ctrl Key, Right click and F12

<script language="JavaScript">

//////////F12 disable code////////////////////////
    document.onkeypress = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
           //alert('No F-12');
            return false;
        }
    }
    document.onmousedown = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            //alert('No F-keys');
            return false;
        }
    }
document.onkeydown = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            //alert('No F-keys');
            return false;
        }
    }
/////////////////////end///////////////////////


//Disable right click script
var message="Sorry, right-click has been disabled";

function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
//
function disableCtrlKeyCombination(e)
{
//list all CTRL + key combinations you want to disable
var forbiddenKeys = new Array('a', 'n', 'c', 'x', 'v', 'j' , 'w');
var key;
var isCtrl;
if(window.event)
{
key = window.event.keyCode;     //IE
if(window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
else
{
key = e.which;     //firefox
if(e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
//if ctrl is pressed check if other key is in forbidenKeys array
if(isCtrl)
{
for(i=0; i<forbiddenKeys.length; i++)
{
//case-insensitive comparation
if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
{
//alert('Key combination CTRL + '+String.fromCharCode(key) +' has been disabled.');
return false;
}
}
}
return true;
}
</script>
</head>
<body onkeypress="return disableCtrlKeyCombination(event);" onkeydown="return disableCtrlKeyCombination(event);">
Press ctrl and you can check various key is disable with CTRL. like  — 'a', 'n', 'c', 'x', 'v', 'j' , 'w' Just add key in above the array and disable key as you want.
</body>
</html> 

Monday, August 18, 2014

How do I link a CSS file to my page?

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

How to add a custom widget area in WordPress

First you’ll want to add this code to your active theme’s function.php file. This code is used to register the custom widget area and create it on the backend.





// Custom widget area.
 register_sidebar( array(
    'name' => __( 'Custom Widget Area'),
    'id' => 'custom-widget-area',
    'description' => __( 'An optional custom widget area for your site', 'twentyten' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => "</li>",
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
) );

In above code you can give your own id and own name.
 
While creating multiple widget area you should keep the id different for each one.


Next you want to add this code to whichever page template you’d like the widget area to show on. This code is used to display the custom widget area in any location you choose within your theme’s files.






<?php
// Custom widget area start
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Custom Widget Area') ) : ?>
<?php endif; ?>

Saturday, August 02, 2014

URL Encoded Characters

 backspace      %08
      tab            %09
      linefeed       %0A
      creturn        %0D
      space          %20
      !              %21
      "              %22
      #              %23
      $              %24
      %              %25
      &              %26
      '              %27
      (              %28
      )              %29
      *              %2A
      +              %2B
      ,              %2C
      -              %2D
      .              %2E
      /              %2F
      0              %30
      1              %31
      2              %32
      3              %33
      4              %34
      5              %35
      6              %36
      7              %37
      8              %38
      9              %39
      :              %3A
      ;              %3B
      <              %3C
      =              %3D
      >              %3E
      ?              %3F
      @              %40
      A              %41
      B              %42
      C              %43
      D              %44
      E              %45
      F              %46
      G              %47
      H              %48
      I              %49
      J              %4A
      K              %4B
      L              %4C
      M              %4D
      N              %4E
      O              %4F
      P              %50
      Q              %51
      R              %52
      S              %53
      T              %54
      U              %55
      V              %56
      W              %57
      X              %58
      Y              %59
      Z              %5A
      [              %5B
      \              %5C
      ]              %5D
      ^              %5E
      _              %5F
      `              %60
      a              %61
      b              %62
      c              %63
      d              %64
      e              %65
      f              %66
      g              %67
      h              %68
      i              %69
      j              %6A
      k              %6B
      l              %6C
      m              %6D
      n              %6E
      o              %6F
      p              %70
      q              %71
      r              %72
      s              %73
      t              %74
      u              %75
      v              %76
      w              %77
      x              %78
      y              %79
      z              %7A
      {              %7B
      |              %7C
      }              %7D
      ~              %7E
      ¢              %A2
      £              %A3
      ¥              %A5
      |              %A6
      §              %A7
      «              %AB
      ¬              %AC
      ¯              %AD
      º              %B0
      ±              %B1
      ª              %B2
      ,              %B4
      µ              %B5
      »              %BB
      ¼              %BC
      ½              %BD
      ¿              %BF
      À              %C0
      Á              %C1
      Â              %C2
      Ã              %C3
      Ä              %C4
      Å              %C5
      Æ              %C6
      Ç              %C7
      È              %C8
      É              %C9
      Ê              %CA
      Ë              %CB
      Ì              %CC
      Í              %CD
      Î              %CE
      Ï              %CF
      Ð              %D0
      Ñ              %D1
      Ò              %D2
      Ó              %D3
      Ô              %D4
      Õ              %D5
      Ö              %D6
      Ø              %D8
      Ù              %D9
      Ú              %DA
      Û              %DB
      Ü              %DC
      Ý              %DD
      Þ              %DE
      ß              %DF
      à              %E0
      á              %E1
      â              %E2
      ã              %E3
      ä              %E4
      å              %E5
      æ              %E6
      ç              %E7
      è              %E8
      é              %E9
      ê              %EA
      ë              %EB
      ì              %EC
      í              %ED
      î              %EE
      ï              %EF
      ð              %F0
      ñ              %F1
      ò              %F2
      ó              %F3
      ô              %F4
      õ              %F5
      ö              %F6
      ÷              %F7
      ø              %F8
      ù              %F9
      ú              %FA
      û              %FB
      ü              %FC
      ý              %FD
      þ              %FE
      ÿ              %FF

Wednesday, July 30, 2014

Validation for radio button

<script>
function send()
{
var genders = document.getElementsByName("genders");
if ( (genders[0].checked == false) && (genders[1].checked == false) && (genders[2].checked == false) && (genders[3].checked == false)) {
alert("it is empty");
return false;
}
return true;
}
</script>

Disable KeyDown And Ctrl key

<script>
document.onkeydown = function() {
    alert();   
    switch (event.keyCode) {
        case 116 : //F5 button
            event.returnValue = false;
            event.keyCode = 0;
            return false;
        case 82 : //R button
            if (event.ctrlKey) {
                event.returnValue = false;
                event.keyCode = 0; 
                return false;
            }
    }
}
</script>

Disable Right Click In all browser's

<script language="javascript">

                   var message="This function is not allowed here.";
                   function clickIE4(){

                                 if (event.button==2){
                                 alert(message);
                                 return false;
                                 }
                   }

                   function clickNS4(e){
                                 if (document.layers||document.getElementById&&!document.all){
                                                if (e.which==2||e.which==3){
                                                          alert(message);
                                                          return false;
                                                }
                                        }
                   }

                   if (document.layers){
                                 document.captureEvents(Event.MOUSEDOWN);
                                 document.onmousedown=clickNS4;
                   }

                   else if (document.all&&!document.getElementById){
                                 document.onmousedown=clickIE4;
                   }

                   document.oncontextmenu=new Function("alert(message);return false;")

    </script>

Tuesday, July 29, 2014

Script to stop the function of Right click and F5

<script language="javascript" type="text/javascript">
window.history.forward(1);
document.attachEvent("onkeydown", my_onkeydown_handler);
function my_onkeydown_handler()
{
switch (event.keyCode)
{
case 116 : // 'F5'
event.returnValue = false;
event.keyCode = 0;
//window.status = "We have disabled F5";
break;
}
}
document.onmousedown=disableclick;
status="Right Click is not allowed";
function disableclick(e)
{
if(event.button==2)
{
alert(status);
return false;
}
}
</script>

NOTE:-Works only in IE.

Disable refresh key(F5)

Use the below code to disable your F5 key on browser:-

document.onkeydown = function() {
        if(event.keyCode == 116) {
                event.returnValue = false;
                event.keyCode = 0;
                return false;
               }
    }



Put this code simply in the script.(NOTE:- Works only in IE).

Monday, July 28, 2014

From validation using javascript

<script type="text/javascript">
function checkForm(reg_form)
{
if(reg_form.name.value == "")
{
alert("Error: Name cannot be blank!");
reg_form.name.focus();
return false;
}
re = /^\w+$/;
if(!re.test(reg_form.name.value))
{
alert("Error: Name must contain only letters, numbers and underscores!");
reg_form.name.focus();
return false;
}
if(reg_form.u_rollno.value == "")
{
alert("Error: university rollno cannot be blank!");
reg_form.name.focus();
return false;
}
re = /^\w+$/;
if(!re.test(reg_form.name.value))
{
alert("Error: University roll no must contain only letters, numbers and underscores!");
reg_form.name.focus();
return false;
}

if(reg_form.sem.value == "")
{
alert("Error: Semester cannot be blank!");
reg_form.name.focus();
return false;
}
re = /^\w+$/;
if(!re.test(reg_form.sem.value))
{
alert("Error: Semester must contain only letters, numbers and underscores!");
reg_form.sem.focus();
return false;
}
if(reg_form.branch.value == "")
{
alert("Error: branch cannot be blank!");
reg_form.branch.focus();
return false;
}
re = /^\w+$/;
if(!re.test(reg_form.branch.value))
{
alert("Error: branch must contain only letters, numbers and underscores!");
reg_form.branch.focus();
return false;
}
if(reg_form.c_id.value == "")
{
alert("Error: College id cannot be blank!");
reg_form.c_id.focus();
return false;
}

var x = document.forms["reg_form"]["email"].value;
    var atpos = x.indexOf("@");
    var dotpos = x.lastIndexOf(".");
    if (atpos< 1 || dotpos<atpos+2 || dotpos+2>=x.length) {
        alert("Not a valid e-mail address");
        return false;
    }

if(reg_form.password.value != "" && reg_form.password.value == reg_form.c_password.value)
{
if(reg_form.password.value.length < 6)
{
alert("Error: Password must contain at least six characters!");
reg_form.password.focus();
return false;
}
if(reg_form.password.value == reg_form.name.value)
{
alert("Error: Password must be different from Username!");
reg_form.password.focus();
return false;
}
re = /[0-9]/;
if(!re.test(reg_form.password.value))
{
     alert("Error: password must contain at least one number (0-9)!");
     reg_form.password.focus();
     return false; }
     re = /[a-z]/;
if(!re.test(reg_form.password.value))
{
     alert("Error: password must contain at least one lowercase letter (a-z)!");
     reg_form.password.focus();
     return false;
}
re = /[A-Z]/;
if(!re.test(reg_form.password.value))
{
    alert("Error: password must contain at least one uppercase letter (A-Z)!");
    reg_form.password.focus();
    return false;
}
}
else
{
     alert("Error: Please check that you've entered and confirmed your password!");
     reg_form.password.focus();
     return false;
}
}
</script>
<center>
<table  cellpadding="10" cellspacing="10">
<form action="reg_action.php" onSubmit="return checkForm(this);" method="post" name="reg_form">
<tr>
<td>Name:</td>
<td><input type="text" size="20" name="name" /></td>
</tr>
<tr>
<td>University Roll No:</td>
<td><input type="text" size="20" name="u_rollno" /></td>
</tr>
<td>Semester:</td>
<td><input type="text" size="20" name="sem" /></td>
</tr>
<tr>
<td>Branch:</td>
<td><input type="text" size="20" name="branch" /></td>
</tr>
<tr>
<td>College id:</td>
<td><input type="text" size="20" name="c_id"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" size="20" name="email" /></td>
</tr>
<tr>
<td>Phone No:</td>
<td><input type="text" size="20" name="phone_no" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" size="20" name="password" /></td>
</tr>
<tr>
<td>Conform Pssword:</td>
<td><input type="password" size="20" name="c_password" /></td>
</tr>
<tr>
<tr>
<td></td>
<td><input type="submit" value="REGISTER" >  <input type="reset" value="RESET"></td>
</tr>
</form>
</table>
</center>
</html>

Submit Form on Refresh or move to another Page

<script type="text/javascript">
 function finishpage()
{
alert("unload event detected!");
document.quiz.submit();
}
window.onbeforeunload= function() {
setTimeout('document.quiz.submit()',1);
}
</script>

Friday, July 25, 2014

How to submit an form after an time interval?

<?php
include("config.php");
$sql=mysql_query("select * from timer");
$row_2=mysql_fetch_array($sql);
$row_2['num_timer'];
?>


 <div style="font-weight: bold" id="quiz-time-left"></div>

<script type="text/javascript">
var max_time = <?php echo $row_2['num_timer'] ?>;
var c_seconds  = 0;
var total_seconds =60*max_time;
max_time = parseInt(total_seconds/60);
c_seconds = parseInt(total_seconds%60);
document.getElementById("quiz-time-left").innerHTML='Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds';
function init(){
document.getElementById("quiz-time-left").innerHTML='Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds';
setTimeout("CheckTime()",999);
}
function CheckTime(){
document.getElementById("quiz-time-left").innerHTML='Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds' ;
if(total_seconds <=0){
setTimeout('document.quiz.submit()',1);
  
    } else
    {
total_seconds = total_seconds -1;
max_time = parseInt(total_seconds/60);
c_seconds = parseInt(total_seconds%60);
setTimeout("CheckTime()",999);
}

}
init();
</script>


<form method="post" name="quiz" id="quiz_form" action="query.php" >
</form>

Auto submit (onload) a HTML Form

<form id="myForm" name="myForm" action="http://example.com/examplePage.do" method="POST">
<input type=text name="val1" id="val1" value="value1"/>
<input type=text name="val2" id="val2" value="value2"/>
<input type=text name="val3" id="val3" value="value3"/>
<input type=text name="submit" id="submit" value="Continue"/>
</form>



 Use the below code:-




<html>
<body onload="document.createElement('form').submit.call(document.getElementById('myForm'))">
<form id="myForm" name="myForm" action="http://example.com/examplePage.do" method="POST">
<input type=hidden name="val1" id="val1" value="value1"/>
<input type=hidden name="val2" id="val2" value="value2"/>
<input type=hidden name="val3" id="val3" value="value3"/>
<input type=hidden name="submit" id="submit" value="Continue"/>
</form>
</body>
</html>

Friday, July 18, 2014

How to Import large sql file to WAMP/phpmyadmin?

Step 1: Find the config.inc.php file located in the phpmyadmin directory. In my case it is located here:

C:\wamp\apps\phpmyadmin3.4.5\config.inc.php 

Note: phymyadmin3.4.5 folder name is different in different version of wamp

Step 2: Find the line with $cfg['UploadDir'] on it and update it to:

$cfg['UploadDir'] = 'upload';

Step 3: Create a directory called ‘upload’ within the phpmyadmin directory.

C:\wamp\apps\phpmyadmin3.2.0.1\upload\

Step 4: Copy and paste the large sql file into upload directory which you want importing to phymyadmin

Step 5: Select sql file from drop down list from phymyadmin to import.