hello friend, i ust need your help
when i insert in database i go to page of my choice on local alla work fine but on server it don't work when i insert a data the page just refresh,
this is the code please help me friend

("INSERT INTO commande (client, `date`, subtotal, total) VALUES (%s, %s, %s, %s)",
                       GetSQLValueString($_POST['client'], "text"),
                       GetSQLValueString($_POST['date'], "date"),
                       GetSQLValueString($_POST['subtotal2'], "double"),
                       GetSQLValueString($_POST['total'], "int"));

  mysql_select_db($database_marketbase, $marketbase);
  $Result1 = mysql_query($insertSQL, $marketbase) or die(mysql_error());

  $insertGoTo = "myspace/order-line.php"; // here isi the problem on local work fine but on server the page where i'm just refresh
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
Member Avatar for LastMitch

$insertgoto a php variable in dreamweaver work on…

@chrisschristou

I don't understand your question?

$insertGoTo = "myspace/order-line.php";

You don't do that? Where did learn to do that?

Your

$insertGoTo = " ";

should have values from the database. Another words, a query statement fetching data from the database.

I don't see a query for that. Your INSERT statements look fine not sure your table structure.

It should be include() function for a file:

include 'myspace/order-line.php';

echo "$insertGoto";

That will make more sense. Does it make sense to you?

the more code are generated by Dreamweaver cs6 on local on wamp it work fine but when i upluad on server it don't work..

Member Avatar for LastMitch

@chrisschristou

the more code are generated by Dreamweaver cs6 on local on wamp it work fine but when i upluad on server it don't work..

You have understand something very simple.

What error did you get on your host server?

You kept saying it doesn't work and it's not really help at all.

There's always an error related to a database.

this is how i edit it still same :(

}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "valide")) {
  $insertSQL = sprintf("INSERT INTO commande (client, `date`, subtotal, total) VALUES (%s, %s, %s, %s)",
                       GetSQLValueString($_POST['client'], "text"),
                       GetSQLValueString($_POST['date'], "date"),
                       GetSQLValueString($_POST['subtotal2'], "double"),
                       GetSQLValueString($_POST['total'], "int"));

  mysql_select_db($database_marketbase, $marketbase);
  $Result1 = mysql_query($insertSQL, $marketbase) or die(mysql_error());

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

i dont get error but just the same page resfresh i would like to gon on order-line.php page on my local server (wamp it work with my first code) thank to help me

If you're just trying to redirect why aren't you using the header(); function and placing the form processor code (Your isset code) above any HTML on the page to avoid headers already sent errors?

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "valide")) {
  $insertSQL = sprintf("INSERT INTO commande (client, `date`, subtotal, total) VALUES (%s, %s, %s, %s)",
                       GetSQLValueString($_POST['client'], "text"),
                       GetSQLValueString($_POST['date'], "date"),
                       GetSQLValueString($_POST['subtotal2'], "double"),
                       GetSQLValueString($_POST['total'], "int"));
  mysql_select_db($database_marketbase, $marketbase);
  $Result1 = mysql_query($insertSQL, $marketbase) or die(mysql_error());

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

  //This will take user to your defined location
  header('Location: http://url.com/'.$insertGoTo);

the code is when a user place a order.... how i will use the header ???? i'm not good in php only in HTML :D

When this function is called: header('Location: http://url.com/'.$insertGoTo); users are redirected to the script defined after 'Location:'.

Make sure you have all your PHP processing ABOVE any HTML.

still same don't work it refresh the same page

Then it's another part of your code causing the issue... right? Can you add your while script please, easier to work with too. It would also ne nice to know the name of the current file and the value of $_SERVER['Query_String'];

here is my whole page ... can't undestund why it work on local server and not on hosting server...

<?php require_once('../folder/marketbase.php'); ?>
<?php session_start(); ?>
<!doctype html>
<html><!-- InstanceBegin template="/Templates/mainpage.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>My shopping card</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="../style/thrColFixHdr.css" rel="stylesheet" type="text/css">
<link href="../style/zunaphonestyle.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="outbarexcuse"> <p>To all our customers we work on site to update the ergonomic, </p>
  <p> we are at your service please feel free to contact us</p>
  <p class="mail">service@zunaphone.com
</p></div>
<div class="container">
   <div class="conect">
<ul>
<li><a href="singin.php">Login</a></li>
<li></li>
<li><a href="index.php"> My Account</a></li>
<li><!-- #BeginLibraryItem "/myspace/logout.lbi" --><?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);

  $logoutGoTo = "../tabandphone.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<meta charset="utf-8">
<style type="text/css">
.logout {
    width: 45px;
}
</style>

<div class="logout">
<a href="<?php echo $logoutAction ?>">Logout</a>
</div><!-- #EndLibraryItem --></li>
<li><a href="singup.php">Be member</a></li>
</ul>
</div>
  <div class="header"><a href="" title="zunaphone.com"><img src="../images/logo.png" alt="Insérer le logo ici" name="Insert_logo" width="302" height="80" usemap="#Insert_logoMap" id="Insert_logo" style="background-color:  display:block;" border="0" />
      <map name="Insert_logoMap">
        <area shape="circle" coords="228,49,39" href="www.zunaphone.com">
        <area shape="rect" coords="254,52,296,75" href="www.zunaphone.com" alt="zunaphone.com">
        <area shape="rect" coords="0,-1,200,36" href="www.zunaphone.com" alt="zunaphone.com">
      </map>
  </a>
    <div class="searchbox">
      <p>

      <form name="form1" method="post" action="../product/result.php">
        <label for="search"></label>
        <input name="search" type="text" id="search" value="Keyword">
        <input type="submit" name="go" id="go" value="Search">
      </form>
      </p>
    </div>
    <div class="tetenav">
      <ul class="headnav">
        <li><a href="../index.php">Home</a></li>
        <li><a href="../tabandphone.php">Tablet And Phone</a></li>
        <li><a href="../phones.php">Android Phones</a></li>
        <li><a href="../tabletpc.php">Android Tablet Pc</a></li>
        <li><a href="../accesories.php">Accesories</a></li>
      </ul>
    </div>

  <!-- end .header --></div>
  <div class="sidebar1">
    <ul class="nav">
      <li><a href="../quadcorephone.php">Quad core Phones</a></li>
      <li><a href="../dualcorephone.php">Dual core Phones</a></li>
      <li><a href="../fhdphones.php">FHD Phones</a></li>
      <li><a href="../hdphones.php">HD phones</a></li>
      <li><a href="../7ichtabletpc.php">7 inch Tablet</a></li>
      <li><a href="../9nchtabletpc.php">9 inch Tablet</a></li>
      <li><a href="../10inchtabletpc.php">10 inch Tablet</a></li>
      <li><a href="../quadcoretab.php">Quad Core Tablet </a></li>
      <li><a href="../dualcoretab.php">Dual core Tablet</a></li>
      <li><strong>To all zunaphone.com customers we are updating the site will fix the problem asap, sorry for the troubles !thank you </strong></li>
    </ul>
    <!-- InstanceBeginEditable name="EditRegion4" -->
    <?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "failed.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
    <?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

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

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "editquantite")) {
  $updateSQL = sprintf("UPDATE panier SET client=%s, article=%s, SKU=%s, quantite=%s WHERE id=%s",
                       GetSQLValueString($_POST['idclient'], "text"),
                       GetSQLValueString($_POST['article'], "text"),
                       GetSQLValueString($_POST['skudproduit'], "text"),
                       GetSQLValueString($_POST['quantite'], "int"),
                       GetSQLValueString($_POST['idcomande'], "int"));

  mysql_select_db($database_marketbase, $marketbase);
  $Result1 = mysql_query($updateSQL, $marketbase) or die(mysql_error());

  $updateGoTo = "panier.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "valide")) {
  $insertSQL = sprintf("INSERT INTO commande (client, `date`, subtotal, total) VALUES (%s, %s, %s, %s)",
                       GetSQLValueString($_POST['client'], "text"),
                       GetSQLValueString($_POST['date'], "date"),
                       GetSQLValueString($_POST['subtotal2'], "double"),
                       GetSQLValueString($_POST['total'], "int"));

  mysql_select_db($database_marketbase, $marketbase);
  $Result1 = mysql_query($insertSQL, $marketbase) or die(mysql_error());

  $insertGoTo = "myspace/order-line.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    echo $insertGoTo;
  }
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

  mysql_select_db($database_marketbase, $marketbase);
}
  mysql_select_db($database_marketbase, $marketbase);
$paramclient_panier = "0";
if (isset($_SESSION['MM_Username'])) {
  $paramclient_panier = $_SESSION['MM_Username'];
}
mysql_select_db($database_marketbase, $marketbase);
$query_panier = sprintf("SELECT panier.id,panier.quantite,panier.client,  phone.titre,panier.sku, phone.prix,phone.shipping,(panier.quantite*phone.prix) AS subtotal FROM panier INNER JOIN  phone ON panier.sku=phone.sku WHERE panier.client=%s", GetSQLValueString($paramclient_panier, "text"));
$panier = mysql_query($query_panier, $marketbase) or die(mysql_error());
$row_panier = mysql_fetch_assoc($panier);
$totalRows_panier = mysql_num_rows($panier);

$paramclient_total = "0";
if (isset($_SESSION['MM_Username'])) {
  $paramclient_total = $_SESSION['MM_Username'];
}
mysql_select_db($database_marketbase, $marketbase);
$query_total = sprintf("SELECT now() AS date,phone.shipping, SUM(panier.quantite*phone.prix) AS sub_total, SUM(panier.quantite*phone.prix+phone.shipping) AS total FROM panier INNER JOIN phone ON phone.sku=panier.sku WHERE panier.client=%s GROUP BY panier.client", GetSQLValueString($paramclient_total, "text"));
$total = mysql_query($query_total, $marketbase) or die(mysql_error());
$row_total = mysql_fetch_assoc($total);
$totalRows_total = mysql_num_rows($total);
?>
    <p>&nbsp;</p>
    <!-- InstanceEndEditable --><!-- end .sidebar1 --></div>
  <!-- InstanceBeginEditable name="EditRegion3" -->
  <div class="content">
    <div class="cntnu">
      <?php do { ?>
        <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="editquantite">
          <label for="article"></label>
          <input name="article" type="text" disabled class="champ" id="article"  value="<?php echo $row_panier['titre']; ?>" readonly>
          <label for="quantite">quantite</label>
          <input name="quantite" type="text" id="quantite" value="<?php echo $row_panier['quantite']; ?>" size="3">
          <input name="idcomande" type="hidden" id="hiddenField" value="<?php echo $row_panier['id']; ?>">
          <input name="idclient" type="hidden" id="hiddenField2" value="<?php echo $row_panier['client']; ?>">
          <input name="skudproduit" type="hidden" id="hiddenField3" value="<?php echo $row_panier['sku']; ?>">
          <input type="hidden" name="MM_update" value="editquantite">
          <input type="submit" name="update" id="update" value="update quantity">
          <a href="deleteitem.php" onclick="return confirm('Are you sure you want to delete the raw number <?php echo $donnees['id']; ?> ?')">Delete</a>
        <label for="subtotal"></label>
        <input name="subtotal" type="text" disabled id="subtotal" value="<?php echo number_format ($row_panier['subtotal'], 2, '.', ''); ?>" size="5" readonly>
        </form>
        <?php } while ($row_panier = mysql_fetch_assoc($panier)); ?>

      <div class="valide">
        <form name="valide" method="POST" action="<?php echo $editFormAction; ?>">
          <label for="Sub total"></label>
          <label for="shipping">Sub total</label><input name="subtotal2" type="text" disabled value="<?php echo number_format($row_total['sub_total'], 2, '.', ''); ?>" readonly disabledid="subtotal2">
          <label for="shipping">Shipping</label>
           <input name="shipping" type="text" id="shipping" value="<?php echo number_format($row_total['shipping'], 2, '.', ''); ?>" readonly>
          <label for="total"></label>
          <label for="shipping">Total</label><input name="total" type="text" disabled id="total" value="<?php echo number_format ($row_total['total'], 2, '.', ''); ?>" readonly>
          <input name="date" type="hidden" id="date" value="<?php echo $row_total['date']; ?>">
          <input type="hidden" name="client" id="client" value="<?php echo $_SESSION['MM_Username'] ?>">
<input type="submit" name="button" id="button" value="Place an order">
<input type="hidden" name="MM_insert" value="valide">
        </form>
      </div>

    </div>
  </div>
  <!-- InstanceEndEditable -->
  <div class="sidebar2"><!-- InstanceBeginEditable name="EditRegion5" -->
    <h4>&nbsp;</h4>
    <p>&nbsp;</p>
    <!-- InstanceEndEditable --><!-- end .sidebar2 --></div>
  <div class="footer">
    <p>Hight quality product: find hight quality dual and quad core smart-phones and dual and quad core tablet pc cheapest price on web, fast world wide shipping, hight quality product and waranty 1 years, 2h/7 days customers service: service@zunaphone.com best customers service ever.</p>
    <!-- end .footer --></div>
  <!-- end .container --></div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($panier);

mysql_free_result($total);
?>

here is my whole page ... can't undestund why it work on local server and not on hosting server...

That's fairly easy to answer, different versions of PHP or different PHP configuration settings. Apache settings could also have an effect. Let me look at your code and get back to you.

You didn't take on board my advice of having your PHP form processors above any html output, you have a header function below PHP - it will result in a fatal error.

sure i used your advice and when it din't work i delete to show you my whole code :( ;( hope you are not angry at me i will edit how i used

i'm not able to edit the preview code but here is how i used it

  $insertGoTo = "myspace/order-line.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    echo $insertGoTo;
    header('Location: http://www.zunaphone.com/myspace/order-line.php/'.$insertGoTo);
  }
  header(sprintf("Location: %s", $insertGoTo));
}

Angry? I'm not angry haha, just in and out of meetings, I'll look back when i can, sorry!

Member Avatar for LastMitch

@chrisschristou

The code you post is really a mess. I find hard to read what you did.

Are you using a e-comm platform and you are trying to modify the template?

If so, then it would be OK.

But if not, then you need to make sure that your code & files is secure if not someone will able to hack to your server and that won't be good for any busniess that is using that template.

I assume you didn't write this code because it's not really organzied.

As much as mmcdonald explain to you what to do, I feel you are not grasping what mmcdonald asking you to do.

hello i don't use e-comm platform template is generated in dreamweaver

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.