Multiple Redirection Error

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


It is a Error When request send by the header becomes Recursive which leads to infinite looping and page donot respond.

such Error is called Redirection error.


If you have GET Request and Header("location:<target>") is called to same page at the GET request then such Error is seen.


For Example:

input.php

header("location:input.php");


How to reset the form fields  after form submit

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

Generally for better response you can take user redirect from current page another page.

But for resetting the form fields on the same page

Multiple Ways


1. Using Header-location on REQUEST POST

  here we can use header location and pass some message with query string and later on use it as a flash data

  

  Steps 1: 

  include 'errors.php';

  include 'function';

  

  Steps 2:

  $msg['register-success'] = '<span style="color:green"> &#10004;Registration Done </span>';

  

  Steps 3:

  header("location:input.php?msg=register-success");


Steps 4:

<?php show_errors(); ?>


Case 2:

Alert using php


echo "<script>window.alert('Your Message');window.location.href='form.php';</script>";


Case 3:

Classic Way:

  $name = "";

  $mobile = "";

  

  Best Way:

  

  foreach($_POST as $k => $value){

    $$k="";

  }

  echo 'Form submitted';

  

  Case 4:

  using Pure JavaScript

  document.getElementByIdClassname()

  

  Create a Common class-name

  class="input-box"

  

  and generate script tag dynamically only when foem is submitted

  $submit=false;

  before submitting

  after submitting

  $submit = true;

  After Body Tag:


  <?php if($submit==true){?>

   <script>

     var classelement = document.getElementByIdClassname('input-box');

for(var i=0;i<classelement.length;i++){

   classelement[i].value="";

}

   </script>

<?php }?>


How to get and set in Textarea

<textarea name="address"></textarea>

$address=$_POST['address'];


Set:

<textarea><?php echo $address; ?></textarea>



How to get and set in select Box

<select name="city">

  <option value='banda'>Banda</option>

  </select>

  $city = $_POST['city'];

  echo $city


 

Database


Student

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

ID | Name | Hobbies

1  | Ravi | singing

2  | Ram  | singing,dancing,cooking,crying