hello dear friend.
on my page i have a form with data with submit bouton when user click on insert data insert into a table all work fine i would like to redirect user to other page after insert into the i use this code

 $insertGoTo = 'order-line.php';
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    echo $insertGoTo;
  }
  die ($insertGoTo);
  header(sprintf("Location: %".$insertGoTo));
}

on my local server it work fine but on my hosting server the pages is just refresh and and in side this one apear order-line.php?order-line.php?

Recommended Answers

All 10 Replies

Remove line 5 and 7, and the % on line 8.

i have change like say page is still refreshing when i clik on submit bouton and no error message only smal remark this the question symbol (?) apear after page.php? on the search bar

$insertGoTo = 'order-line.php';
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: ".$insertGoTo));
    }

can somebody help here plaese???

It looks fine to me, but what I wonder about is the } on line 7. Looks like this is not all code you have.

this is the code after line 7

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

and after are my dabase data selction....

// I M trying to redirect to another pager after inserting data into database but its not redirecting...can any one help in this

<?php
$dbhost='localhost';
$dbuser='shitanshu';
$dbpass='123';
$dbname='placment';

$conn=(@mysql_connect($dbhost,$dbuser,$dbpass));
                (@mysql_select_db($dbname));

$ccname=$_POST['ccname'];
$ccemail=$_POST['ccemail'];
$ccpass=$_POST['ccpass'];
$ccrepass=$_POST['ccrepass'];
$cccontact=$_POST['cccontact'];


                $sql="INSERT INTO companyreg (ccname,ccemail,ccpass,ccrepass,cccontact) VALUES('$ccname','$ccemail','$ccpass','$ccrepass','$cccontact')";
                $result=mysql_query($sql);
                if($result!=null)
                {
                header("Location:cmenu.php");
                }

?>

Replace if($result!=null) with if($result)

$result is never null. It will contain true, false or a resource.

still it is not redirecting

Do this and find out if there is a problem:

$result = mysql_query($sql) or die(mysql_error());

still problem is arising page is not redirecting but data is inserting into database

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.