Thursday, 25 April 2019

Easiest Way To Disable Form Submit On Enter Pressed | Javascript Tutorial | All Web-App Languages


avoid_direct_submit_form.php
<form action="receive.php" method="post">
<input type="text" name="fname" placeholder="first name" autocomplete="off" onkeydown="javascript: return random_function(event)">
<input type="text" name="lname" placeholder="first name" autocomplete="off" onkeydown="javascript: return random_function(event)">
<input type="submit" name="" value="submit">
</form>
<script type="text/javascript">
function random_function(evt)
{
var bool=true;
if(evt.keyCode==13)
{
bool=false;
}
return bool;
}

</script>

receive.php
<?php
echo "first name is ".$_POST['fname']. " and last name is ".$_POST['lname'];
?>
Stopping Form from submitting when “ENTER” key pressed.
Hello guys, this is unpossible pog here.
This tutorial will be about how you can stop submitting form when “Enter key” pressed.
As you can see I created one file with HTML form which submits form when “ENTER” key is pressed.
Second file contains php code to receive data.
Create a keydown attribute and type this.
Make sure to type event in rounded brackets.
Paste it at any textbox you want.
Then create that function in script tag. Dont forget to type evt argument.
Lets create a boolean variable.
Lets alert the keycode. C is capital.
If I hit “A” on keyboard, it alerts me its code 65.
And 66 is for B.
The “ENTER” key has keycode 13.
So we just have to change boolean variable “FALSE”, then return it.
Let’s test it.
If I type any keywords, it allows me to but it will not allow me to submit form when
ENTER is pressed.

Thank you for watching, dont forget to like share and subscribe.

Tuesday, 19 March 2019

PHP | Get List Of Dates Between Two Days

index.php
<form action="display_dates.php" method="post">
    <input type="date" name="from_date"><br/>
    <input type="date" name="to_date"><br/>
    <input type="submit" name="submit" value="find list of days">
</form>

display_dates.php
<?php
echo "<div>";
echo $From_date= $_POST['from_date'];
echo "</div>";
$to_date= $_POST['to_date'];
$day_count=0;
while(0==0)
{
    
    $day_count++;
    echo "<div>";
    echo $From_date= date('Y-m-d',strtotime($From_date . "+1 days"));
    echo "</div>";
    //if($day_count==10)
    if($From_date==$to_date)
    {
        break;
    }
    
}
?>


Video Description

Hello viewers, In this video I shall make a program to find days between two dates in PHP language.
SO as you can see, I have created one file which has a form.
I shall create a php file where we receive dates from input boxes.
I shall paste that file name in action attribute of form.
Let’s display the output first.
Everything is fine.
Now I shall receive the second date.
Day_counts variable is not that important at the end of program but.
I shall create a while loop and I need day-count variable just for testing.
So I shall break the loop when day-count reaches to 10.
It means the loop is working fine.
Now you can see the pattern of date, where Year comes first, then month then date.
So I shall overwrite the from_date variable and first convert that in date with pattern. Which is Y (dash) M (dash) D, then in second argument I shall convert from_date into time.
In short, first_date is in string, so I am first converting it in time and then in date.
We want next day after each loop, the type (dot) then in double quote, type +1 days.
Now we are hopping to the next days.
Now instead of days_count==10, what we want is if from_date== to_date so just change the condition.
So it means, we are jumping on each date but we have to stop when it reaches to end_date.
We are skipping the first day so just type echo in first lines.
Even when we select next month as end_date, it will work buecause of the inbuild program.
So lest test it, march has 31 days and end date will be 3rd of april.
Just make sure that from date is lesser that end_date otherwise the loop will run forever which is a bug.
Thank you for watching, Dont forget to like share and subscribe.



Wednesday, 27 February 2019

MySql | Find Data Between Dates When Date Is Stored As Varchar | Str_to_date | Select Statement

Code:-

mysql> select * from employee where str_to_date(b_date,'%Y-%m-%d') between str_to_date('2019-2-26','%Y-%m-%d') and str_to_date('2019-2-30','%Y-%m-%d');
| id | name        | b_date    |
|  2 | tony stark  | 2019-2-26 |
|  4 | black widow | 2019-2-27 |
2 rows in set (0.00 sec)


mysql> desc employee;
| Field  | Type        | Null | Key | Default | Extra |
| id     | int(11)     | NO   | PRI | NULL    |       |
| name   | varchar(20) | YES  |     | NULL    |       |
| b_date | varchar(20) | YES  |     | NULL    |       |
3 rows in set (0.03 sec)


mysql> select * from employee;
| id | name         | b_date    |
|  1 | steve rogers | 2019-2-24 |
|  2 | tony stark   | 2019-2-26 |
|  3 | thor odinson | 2019-2-25 |
|  4 | black widow  | 2019-2-27 |

4 rows in set (0.06 sec)


Hello guys, this is unpossible pog and in this video, I shall teach you how to find data between two dates if they are stored as varchar as variable character.

First I shall start mysql by entering username and password.
Then I shall connect to the database, this is case, its sys.

Then as you can see the employee data with the birth dates.
But the b_date is stored as varchar.


So in mysql, there is a function called str_to_date() which converts text to date.
So type command like this in where condition, the first argument will be the column name, which is b_date. Then in second argument, there will be a pattern.
In my database, the pattern is the year – month – date. So I shall type percentage year – percentage month – percentage date.

Thank you for watching, Dont forget to like share and subscribe.






Thursday, 14 February 2019

Youtube Video Manager Bug | 2019 | Bug And How Youtube Developers Can Fi...




On 14th of February 2019, I was checking my old videos inside video manager. By default, youtube's video manager shows videos from newest to oldest. So I was clicking on page links and I saw an unusual thing in my list. There was 2019 live stream within the list of 2016 videos. I don't know how that was happened. As a programmer, the possible things are.

1. It is a bug, means youtube coders neglected live stream video as as ascending order.

2. Maybe one employee changed the date and forgot to reenter it.

3. Some hacker intrude into youtube server and changed date.



Possible fix will be.

1.Go to my database table and change the date.

2. Check if someone hacked youtube or not.



Share this video to reach it to youtube CEO.

Friday, 1 February 2019

Dance Battle In The Forest | Bhimashankar Trekking Via Ganesh Ghat | Hik...










This video is 1st part of the trip. This video will be about "what happened during the journey".
We decided to do the visit bhimashankar temple. There are 3 ways to reach to the temple,
1: By road
2: By Stairs
3: By hiking over the montain.
We chose the third option, that is to trek because our main goal is to look for an adventure and thrill.
After almost completely exhausted by hiking halfway over the mountains, we decided to take a little rest. But it was not fun sitting around in the middle of journey. So we start bluetooth speakers and play songs and we started dancing.

Thursday, 24 January 2019

How To Browse Youtube And Watch Video At The Same Time | Youtube's Minip...





In 2018, youtube introduced a new feature called "Miniplayer".

With this, a user can browse other videos while searching through youtube website. This concept is possibly inspired by mobile apps.

Although the miniplayer floats on window, it can not be dragged anywhere on browser screen, means it always stays at the right bottom. Miniplay is attached with browser, means if you minimize browser then the miniplayer also will be minimized with browser.

I hope there will be new features in miniplayer in future that can be dynamic in nature.

Friday, 21 December 2018

Java Tutorial : Text File As Database Table | Episode 3 | Update Data Fr...



Code :-
import java.io.*;
import java.util.*;
class update_file
{
    public static void main(String ar[])
    {
        update_file uf=new update_file();
        uf.update();       
    }
    public void update()
    {
        /////////phase 1
        System.out.println("Enter the ID of employee that you want to update.....");
        Scanner sc=new Scanner(System.in);
        int id_to_change=sc.nextInt();
        String to_change_column_names[]={"first name:","last name:","Salary:","Location:"};
        int yes_no[]=new int[4];
        String to_update[]=new String[4];

        System.out.println("Select the columns that you want to update (0: No/1: Yes)");
        for(int i=0;i<4;i++)
        {
            System.out.println(to_change_column_names[i]+"");
            int temp=sc.nextInt();
            yes_no[i]=temp;
        }

        ////////////////phase2
        System.out.println("_______________________________________________________");
        System.out.println("Add new values to the columns");
        for(int i=0;i<4;i++)
        {
            System.out.println(to_change_column_names[i]+"");
            if(yes_no[i]==1)
            {
                Scanner sc1=new Scanner(System.in);
                String temp_val=sc1.nextLine();
                to_update[i]=temp_val;   
                System.out.println();
            }
            else
            {
                System.out.println("Cannot be changed");
            }
        }

        //////////////////phase 3
        StringBuffer sb=new StringBuffer();
        try
        {
            BufferedReader br=new BufferedReader(new FileReader("Database.txt"));
            String s="";
            while((s=br.readLine())!=null)
            {
                String data[]=new String[6];
                data=s.split(",");
                if(id_to_change==Integer.parseInt(data[0]))
                {
                    String row=data[0]+",";
                    for(int i=0;i<4;i++)
                    {
                        if(yes_no[i]==1)
                        {
                            row=row+to_update[i]+",";
                        }
                        else
                        {
                            row=row+data[i+1]+",";
                        }

                    }
                    sb.append(row);
                    sb.append("\n");
                }
                else
                {
                    sb.append(s);
                    sb.append("\n");
                }
            }
            //System.out.println(sb.toString());

        ////////////////// phase 4
        File f=new File("Database.txt");
        PrintWriter pw=new PrintWriter(new FileOutputStream(f,false));
        pw.print(sb.toString());
        pw.close();
        }
        catch(Exception e)
        {

        }
    }
}

Hello guys, this is unpossible pog and and on youtube, this guy requested
me to make a code in java to perform update operation.
If
you want to skip intro, then jump to this time.
For
lot of you guys who don’t know, i made tutorials on how to use text
file as database using java.

I only made videos of inserting and
displaying data but not on how to update data.
When
I was trying to write a program however, I found out that it is vary
complex.
Let
me explain you.
SO
this is my table structure with 5 columns.
And
here as you can see, that there can be multiple “SET” keywords
that can be applied to multiple columns, and same goes to “WHERE”
clouse, where there can be multiple condition and other complications
like “AND-OR” and “IN” and “EQUALS TO”.
Now
I shall explain the simplest one, in that there is only unique ID in
condition, but you can select multiple columns.
I
solved the problem of selecting which columns will be updated by
flagging is either as 0 or 1.
If
u didn’t understand it, dont worry, you will understand when I
start writing a code.



Now,
in previous tutorials, we wrote a code on now to insert and display
data from text file. So let me just run it.
As
you can see, the data is entered in text file.



Because
the udate code is huge, I am going to create a new .java file, save
it as the same location where the text file is.
Make
a class and main function.
Now,
there are 4 phases,
In
first phase, we will get which ID will be in where condition and
create some arrays.
Here,
we are not updating ID, because in live projects, we don’t often do
that.
The
Array yes_no are made to give the flag to columns that is O or 1.
In
the for loop, we are asking users to select columns to be updated
Lets
check it, it should be an array.



First,we
will enter ID, then we will type either 0 or 1.
So
far so good.



Now
in second phase,we shall ask user to enter the value of columns which
user want to update.
We
shall store that in “to_change_clumn_names” array.
If
the flag is 1, then , we shall create scanner variable, and insert
values.
In
else, we shall tell user that you can not change this value.



As
you can see, the program is denying user because of the 0 flag he
gave.



In
phase three, we will modify data but won’t upload it in text
file. It will be in phase 4.
But
now in phase 3, we shall get data from text file,now from here, it
gets more complex.
We
shall need, a stringbuffer variable the store the modified value.
In
abstract word, in phase it, we go to each row, and find out whether
it’s ID matches with ID that we enter, if no, then we skip the
change, but if YES, then we find which columns should be updated and
swap their values.
We
append those value in StringBuffer.



Now
lets run it,
Actually
I forgeot to append, when flag is 1.



Now
in phase 3, we are writing the data in text file, it is vary easy.
Make
sure to close the printwriter, otherwise the file won’t be updated.
Lets
run the program and check in text file, whether or not the data has
been modified.
We
shall the value of employee where his ID is 1.



To
confirm it again, we shall the information of ID equals 2.



Thnak
you for watching, Dont forget to like share and subscribe.