Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Sunday, 20 December 2015

code for website automatic redirection

Your questions:

how redirect my website ?
how redirect my website using html ?
how redirect my website using js (javascript) ?
how redirect my website using php ?

Answers:

You can redirect your website (web pages) using html or javascript or php

html code for website redirection:

<meta http-equiv="refresh" content="0;url=http://yournewurl.com"/>

you can redirect your website using this html code 

Javascript code for website redirection:

<script type="text/javascript"> 
window.location="login.php";
 </script>

you can redirect your website using this javascript code 

php code for website redirection:

<?php   header('Location:http://yoursite.com/path/login.php'); ?>

you can redirect your website using php header function 

php form submit without page refresh using angularjs

how to php form submit without page refresh ?

answer:

you can submit input field without page refresh using html , php , angular js
[This example is submit html check box and without page refresh]

angular.min.js

index.php

<!DOCTYPE html>
<html>
<head>
    <script src="angular.min.js"></script>
</head>

<body ng-app="myapp">

<div ng-controller="MyController" >
    <form>

        <input class="singleRoom" type="checkbox" name="firstName" ng-model="myForm.firstName"  ng-true-value="YES" ng-false-value=" " /> First name <br/>

    </form>

    <div>

<?php
       $a=" {{myForm.firstName}} ";
   
   echo $a;    ?>

    </div>
</div>

<script>
    angular.module("myapp", [])
            .controller("MyController", function($scope) {
                $scope.myForm = {};
                
            } );
</script>

</body>
</html>

html and php input form using angular.js

you can submit input field without page refresh using html , php , angular js

[This example is submit html check box and without page refresh]

angular.min.js

index.php


<!DOCTYPE html>
<html>
<head>
    <script src="angular.min.js"></script>
</head>

<body ng-app="myapp">

<div ng-controller="MyController" >
    <form>

        <input class="singleRoom" type="checkbox" name="firstName" ng-model="myForm.firstName"  ng-true-value="YES" ng-false-value=" " /> First name <br/>

    </form>

    <div>

<?php
       $a=" {{myForm.firstName}} ";
  
  echo $a;   ?>

    </div>
</div>

<script>
    angular.module("myapp", [])
            .controller("MyController", function($scope) {
                $scope.myForm = {};
                
            } );
</script>

</body>
</html>

Automatic redirect website page using php header function

Your questions:  

1. how to auto redirect in website using php

2. php code for auto redirect

3. during button click load the same page using php

4. php code for website page auto redirect during validation

[Ex: This code is used in following html and php pages

login ,signin , signup , logout , signout , success , Registration , Error ,  ]


Answer:

 php header function is used to automatic page redirect



<?php   header('Location:http://yoursite.com/path/login.php'); ?>

  

php code for click to load in an other page

Tags: html php script for click link to load in an other page


Example 1:

index.php

<a href="details.php?t=paris"><button>Paris</button></a>
<a href="details.php?t=nice"><button>Nice</button></a>
<a href="details.php?t=bordeaux"><button>Bordeaux</button></a>
<a href="details.php?t=lyon"><button>Lyon</button></a>

details.php

<?php
if(!empty($_GET["t"]))
{
    $t = htmlentities($_GET["t"]);
    switch($t)
    {
        case "paris":
            $title = "Detail of $t";
            $text = "...";
            break;
        case "nice":
            $title "Detail of $t";
            $text = "...";
            break;
        case "bordeaux":
            $title "Detail of $t";
            $text = "...";
            break;
        case "lyon":
            $title "Detail of $t";
            $text = "...";
            break;
        default:
            $title = "You asked $t, but is an unknown town in our database";
            $text = "";
    }
}
?>

in head section

<html>
    <head>
    <?php echo "<title>$title</title>"; ?>
    </head>

in body section

    <body>
        <?php echo "$text"; ?>
    </body>


Example 2:

index.php

<html>
<body>
<a href="details.php?t=paris"><button>Paris</button></a>
<a href="details.php?t=nice"><button>Nice</button></a>
<a href="details.php?t=bordeaux"><button>Bordeaux</button></a>
<a href="details.php?t=lyon"><button>Lyon</button></a>
</body>
</html>

details.php

<?php
if(isset($_GET["t"]))
{
    if($_GET["t"]=="paris")
    {echo "Desc of Paris";}
    else if($_GET["t"]=="nice")
    {echo "Desc of Nice";}
    else if($_GET["t"]=="bordeaux")
    {echo "Desc of Bordeaux";}
    else if($_GET["t"]=="lyon")
    {echo "Desc of Lyon";}
    else{echo "Invalid Title!";}
}
else{echo "no get value found!";}
?>