Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Wednesday, June 29, 2016

How To Get Current URL Without Page Name In PHP

Today I will share a code snippet which will help you get a current URL Without Page Name.

<?PHP

function getPath() {
$protocol = strpos(strtolower($_SERVER[SERVER_PROTOCOL]),https) === FALSE ? http : https;
$host = $_SERVER[HTTP_HOST];
$path = substr($_SERVER[SCRIPT_NAME], 0, -strlen(basename($_SERVER[SCRIPT_NAME])));

return $protocol.://.$host.$path;
}

echo getPath();

?>

This simple piece of code will do the trick.

If you want more such tips and tricks related to PHP then consider subscribing to our blog.

Enjoy!


Monday, June 13, 2016

Restricting admin page to be accessed from only certain ip addresses

If you want to apply someting more secure than just a password to access your admin page you can restrict your admin page to be accessed from only one ip address.

First you should know your ip address. If you dont know you can run this script: 
  <?php
  echo "IP anda : " . $HTTP_SERVER_VARS[REMOTE_ADDR];
?>

Then in the admin area, for example in "administrator/index.php", insert this script on the topmost:

<?php
  $ip = "127.0.0.1" // your ip
  if($HTTP_SERVER_VARS[REMOTE_ADDR] != $ip) {
  header("location: ../index.php");
  } else {
  Setcookie("ip",$ip); }
?>

Then for each file in the admin area, insert this script:

<?php
  $ip = $_COOKIE[ip]; // call cookie ip
  if($HTTP_SERVER_VARS[REMOTE_ADDR] != $ip) {
  echo "You dont have right to access this page!";
  } else {
  // your menu here
  }
?>

Please remember to call cookies or session for your admin username and pasword as well. The example above only call cookie for ip address. 

You may want to apply more than one ip address and store the ip address list in database as following:

CREATE TABLE `web`.`tb_admin` (
  `id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  `ip` VARCHAR( 30 ) NOT NULL
  ) 
 
  INSERT INTO `web`.`tb_admin` (  `id` ,  `ip`  )
  VALUES (1 , 127.0.0.1);

Config.php
<?php
$host = "localhost";
$user = "root";
$pass = "";
$konek = mysql_connect($host,$user,$pass) or die("Check host,user,or password");
$select_db = mysql_select_db("web");
?>

Then in the index.php in the admin folder, you can insert this script:

index.php

<?php
  include("config.php");
  $ip = $HTTP_SERVER_VARS[REMOTE_ADDR];
  $valid_ip = mysql_query("SELECT * FROM tb_admin WHERE ip=$ip");
  if (!= $valid_ip) {
  echo "You dont have permission to access this page!";
  } else {
  // your menu goes here...
  }
?>


Friday, June 10, 2016

Submit PHP Form without Page Refresh using jQuery Ajax

In today's tutorial i am going to share the most useful jQuery functions $.ajax() and $.post(), using these two functions you can submit the PHP Web Forms without Refreshing the whole Web Page of Your Site, The jQuery get() and post() methods are used to request data from the server with an HTTP GET or POST request, hence $.post() function is a Shorthand Ajax method, so this tutorial will guide you that how to use jQuery's $.ajax() and $.post() functions easily to submit PHP Form Data to the Server Web Page without Refreshing the Page, let's see it in detail.
Submit PHP Form without Page Refresh using jQuery, Ajax
Read more »

Saturday, June 4, 2016

Redirect To Another Page In PHP Without Using Header

A little bit of Javascript might help you to rediect to another page.A sample code is given below:

<?php

// show some bits
printf("<html><body>");
printf("Just some bits on this page...");

// do your condition based tests
.....

if ($myConditions != $meetsExpectation)
{
printf("<script>location.href=errorpage.html</script>");
}
else
{
// show other stuffs
}
?>
Hope this leads you in the right diection.Though there are many other ways of doing it,this appears to be the simplest one,isnt it?

If you like this php script the please subscribe to our blog and we will send you updates from this blog right in your Inbox.

Enjoy!

Saturday, May 14, 2016

PHP Login Password Protect A Web Page With This PHP Script

PHP Login script enables web page password protection across as many pages as you want. Just add one line of code for each page you wish to protect. This script is a great way to give your site a strong level of security, fast.

Features:

  • Easy Installation
  • Secures Any Page
  • Brand New Code
  • Fantastic New Look
Download PHP Login Script

Tuesday, April 26, 2016

One Crore Page Hits !

HSSLiVE ???????? ?????????????? ????? ??? ???? ???????!! ???????????????? ??????????... ???????????? ????????... ????????????? ???????? ??????????????????? ???????? ????? ???????????, ??????? ???????????????? ?????????????? ????? ??????? , ??????? ????????? ??????????. ? ??????????? ????????? ??????? ??????? ??? ??????????? ???????????????????????. ? ??????? ??????? ???????????????.
????????????? ?????????? ? ?????? ???????????????? ?????????????????????, ?????????? ??????????????? ????????, ??????, ??????????? ???????????? ?????? ??????? ?????????, ??????????? ??????? ????????????? ???????????? ???? ???????????????? ??????????? ???????, ???????????? ??????????????, ???????? ?????????????? ???????????????? ????? ?????, ????????, ???? ??????? ?????????????,  ????? ??????? ?????????? ?????? ?????????? ???????????? ?????? ??????? ?????????????.
???? ????????? ????? ??????? ????????????????? ?????????? ????????????? ???????????????? ??????????????????? ?????????? ????????? ???????????????????? ? ???????? ?????? ????????. ??????? ? ????????????? ????? ??????????????? ??????????. ????? ??????????????? ??????? ???? ????????????? ???????? ??????. ?????? ??????????????? ??????? ????????????????????, ???????????? ?????????????????. ????????? ???????, ???????? ???????????? ?????????? ?????????????? ???????????? ???????. ????????? ?????????????? ????? ??? ???? ?????????? ????????????? ????????????? ???????????? ?? ?????????. ?????.



Thursday, February 4, 2016

Download Page One Ranking Formula PDF full version


link