Friday, 11 October 2019

PHP Tutorial | Easiest Way To Redirect To Last Visited Page After Login | No Session Or Database

index.php
<?php include('header.php');?>
<h1>This is the INDEX Page</h1>

-------------------
header.php
<?php
$protocol=$_SERVER['SERVER_PROTOCOL'];

if(strpos($protocol, "HTTPS"))
{
    $protocol="HTTPS://";
}
else
{
    $protocol="HTTP://";   
}
$redirect_link_var=$protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
?>
<table width="100%" border="1" cellspacing="0">
    <tr>
        <td><a href="index.php">index</a></td>
        <td><a href="login.php?page_url=<?php echo $redirect_link_var;?>">login</a></td>
        <td><a href="page1.php">page 1</a></td>
        <td><a href="page2.php">page 2</a></td>
        <td><a href="page3.php">page 3</a></td>
    </tr>
</table>

-------------------
login.php

<?php include('header.php');?>
<?php
if($_POST)
{
    if($_POST['username']=="123"&&$_POST['password']=="123")
    {
        $redirect_link=$_REQUEST['page_url'];
        if($redirect_link=="")
        {
            header("location: index.php");
        }
        else
        {
            header("location: ".$redirect_link);   
        }
    }
}
?>
<form action="" method="post">
    <input type="text" name="username">
    <br/>
    <input type="password" name="password">
    <br/>
    <input type="submit" name="" value="login">
</form>

-------------------

page1.php
<?php include('header.php');?>
<h2>This is page 1</h2>
-------------------
page2.php
<?php include('header.php');?>
<h3>This is page 2</h3>
-------------------
page3.php
<?php include('header.php');?>
<h4>This is page 3</h4>

Monday, 30 September 2019

A Trip To Hyderabad & Mallikarjuna Jyotirlinga | Part 2 | Telangana And Andhra Pradesh | Homecoming




After visiting the main place "Mallikarjuna Jyotirlinga", we packed our bags, completely exhausted and went for our first destination to go home, that is, Hyderabad. One of our friend have some friends who live in Hyderabad. We met them, and they helped us exploring the city. The main thing that I was excited about is "Chicken Biryani". After that, we went to hotel, spent night and next day, we catch train. We had fun dancing in train as we always do. Then we reach PUNE and then catch the bus to reach MUMBAI.

Monday, 16 September 2019

PHP Tutorial | Navigate To Next And Previous Week & And Get Dates Within Week











Code : navigate_week.php
<center>


<a href="navigate_week_tutorial.php">Refresh</a>
<br/>
<?php
$week=0;
if(isset($_GET['week_count']))
{
$week=$_GET['week_count'];
}
else
{
$week=date('w');
}
echo "Today's Date :".date('Y-m-d'). " | Day : ".date('D');
echo "<br/>";
echo "First day of week : ".$week_first_date=date('Y-m-d',strtotime("-".(0+$week)." days"));
echo "| Day : ".date('D',strtotime($week_first_date));
echo "<br/>";
echo "Last day of week : ".$week_last_date=date('Y-m-d',strtotime("+".(6-$week)." days"));
echo "| Day : ".date('D',strtotime($week_last_date));
echo "<br/>";
$next_week_var=intval($week)-7;
$previous_week_var=intval($week)+7;
?>


<a href="navigate_week_tutorial.php?week_count=<?php echo $previous_week_var;?>"> << Previous Week</a> 

OR

<a href="navigate_week_tutorial.php?week_count=<?php echo $next_week_var;?>">Next Week >> </a>
<br/>
<?php
for($i=0;$i<=6;$i++)
{
echo $temp_date=date('Y-m-d',strtotime($week_first_date."+".$i." days"));
echo "| Day : ".date('D',strtotime($temp_date));
echo "<br/>";
}
?>
</center>

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/



 Hello guys.
In this tutorial, we
shall discuss how to navigate to each week, how to set range of
weekdays like from monday to sunday, or sunday to saturday, or any
from and to days you want ,and also how to get days of each week.
For example, let say
the current day is 15 sept 2019, so the range will always be of 7
days. But we get days from wednesday to tuesday.
We can also navigate
to next weeks or previous weeks and get dates between them.
So lets get started.
We shall build code
from the scratch.

First we shall get today’s date and day.
Next, I am going to
add refresh link, it’s purpose will be revealed later.
New we shall find
the week-day count using this code.
By using this, we
shall get first day and last of every week.
For first day, we
are using “minus” symbol in strtotime function.
And for last day of
week, we shll use plus sign.
Let get, which day
it is.
Now we shall find
all days between two days by using for loop.

Let make it on
center.
Now we shall add
week navigation, so fot that we have to find two numbers, for next
week and last week.
For previous week,
there will be + 7.
In href, we shall
make a variable called week count. And assign value for previous and
next week.
Now, even when
clicked on link, it doesn’t do anything.
So we have to
overwrite the $week value.
Let test
it.

Acutally I made a mistake in a code.
Ok, so you just have
to add + instead of minus at “Week first date”.
Lets refresh and
test, as you can see, we are hopping on each week.
But what if, we want
start date from monday. So change, like this and as you can see, the
result is coming correctly.
You can select from
day to any day like monday, tuesday wednesday.
So actually, the
main strategy is those numbers, we have to make sure that the
addition between them should be 6.

Let change current date to
17 september.
So no matter what
your current date will be, the code will display every day of every
previous and next weeks.
The code’s link is
in the description.
Thank you for
watching, dont forget to like share and subscribe.




Friday, 6 September 2019

PHP Tutorial | Display Days : Hours : Minutes : Seconds Between Two Dates


Code : 

<h1>

<center>

<?php

$current_date_time_sec=strtotime("2019-8-31 03:45:00");


$future_date_time_sec=strtotime("2019-9-3 00:00:00");


$difference=$future_date_time_sec-$current_date_time_sec;


$hours=($difference / 3600);


$minutes=($difference / 60 % 60);


$seconds=($difference % 60);


$days=($hours/24);


$hours=($hours % 24);


echo "The difference is <br/>";


if($days<0)

{

echo ceil($days). " days AND ";

}

else

{

echo floor($days). " days AND ";

}


echo    sprintf("%02d",$hours).":".sprintf("%02d",$minutes).":".sprintf("%02d",$seconds);


?>

</center>

</h1>




Hello guys.
This tutorial will be about how to get difference between two dates in days,hours,minutes,seconds format.
Lets start code with a scratch.
You have to call a function str_to_time, make sure to provide date-time format same as in the video.
This function gives the number of seconds of each date.
Now we have to calculate the diffrence.
There are formulas for calculating days, minutes, using seconds.
Make sure you type them as it is.
Now the problem is, single digit doesn’t look good, so we have to convert it using sprintf function.
This function will have two argument, 1st for formatting, and 2nd for value.
I forgot to give zero before 2.
Lets try using different numbers.
All good.
Now 49 hours means, 2 days and 1 hour extra.
So, for that, apply other formulas.
We have to overwrite the hour variable.
You see that, the days are in decimal.
So to make it easy to understand, if days are -ve, then use ceil, and if days are +ve, then use floor.
Lets, test it using different dates.
The code is in the description.
Thank you for watching, dont forget to like share and subscribe.

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)


Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/

Friday, 30 August 2019

Mysql Tutorial | Give Priority To Specific Values In Select Query Using ...



Query Examples









1) SELECT * FROM
`employee` order by FIELD(name,"steve rogers","loki")
desc
2) SELECT * FROM
`employee` order by FIELD(salary, id IN (select id from employee
where salary > 300 and salary < 800))








Hello guys.
This tutorial will
be about how to give more priority to specific values in SELECT query
of mysql database server without where clause. And how to fix the
error “subquery returns more than 1 row”. In order by field. For
example, what if you want employee should have more priority where
the salary between 300 and 700 then the rest will be displayed.
The application of
using this will be, getting data which are more related to topic like
google search.
As you can see, i
have one employee table, so instead of using where clause, I am going
to use order by Field, the FIELD is a function, the first argument
will be the calumn name that you want to be ordered, then in other
arguments, you can specify which values you specifically want, in my
case its steve and loki. Make sure to type “DESC” to make sure
that they come on top of list.
But what if you
don’t know how many data should have more priority or if the list
is too large, in that case, we shall use the subquery.
In my case, I want
to give prioritize by salary, so first argument will be salary, and
in second argument, in subquery I am going to call primary key, which
is ID, then apply the condition of salary between 300 and 800.
As you can see, it
is giving me the error that “it is returning more than one row ”
which is obvious. So to fix it, just apply condition “id in”
before subquery.
In result, you can
see that all the data is coming, but employee between salary 300 and
700 have more priority.
Thank you for
watching, dont forget to like share and subscribe.

Saturday, 24 August 2019

A Trip To Hyderabad & Mallikarjuna Jyotirlinga | Telangana And Andhra Pr...



Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/

The trip was a visit to our 4th jyotirlinga out of the 12. In the morning, we thought everything will go smoothly but suddenly we got a message the train from mumbai was cancelled and now we had to go to PUNE to catch that train. So somehow made it vary early. Sadly some people who were already in train didn't know that train will not go to mumbai. We hoped that they reached home safely. The train was empty with few people. In the morning, we realized that we are already outside Maharashtra state which was TELANGANA. After we reached to hyderabad, we quickly catch the BUS to andhra pradesh. Our destination was mallikarjuna Srisailam. Between that BUS journey, we found that there is one DAM near the road. We decided to stop there when we return home.

Thursday, 15 August 2019

Sublime Text 3 Bug | Solution & Avoidance Of Not Highlighting PHP Syntax











Hello guys, this is
unpossible pog here.
Today, I shall talk
about the PHP code not getting highlighted while using SUBLIME text.
I am using the
SUBLIME version 3.2.1.
As you can see, the
PHP code is not highlighted means it is in plain white color.
So I shall tell you
the solution as well as how to avoid PHP not getting highlighted.
The solution is vary
easy.
You just have to
close it and reopen it. Thats it and your PHP code will be
highlighted.
Although how to
avoid it is also vary easy.
Usually when you
copy-paste the code, it creates a problem as you can see.
So to avoid that,
first create empty “untitled” file, paste the code, then save it.
With that, sublime
recognizes PHP code and highlights it automatically.
Thank you for
watching, dont forget to like share and subscribe.