0

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?

3
Contributors
10
Replies
57
Views
4 Years
Discussion Span
Last Post by shitanshu_1
Featured Replies
  • 1

    Replace `if($result!=null)` with `if($result)` `$result` is never null. It will contain true, false or a resource. Read More

0

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));
    }
0

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

0

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....

0

// 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");
                }

?>

Edited by shitanshu_1

1

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

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.