Skip to main content
shoney33
Participating Frequently
December 18, 2013
Answered

Use echo and then redirect

  • December 18, 2013
  • 1 reply
  • 982 views

<?php require_once('../library/connection.php'); ?>

<?php

if (!isset($_SESSION)) {

  session_start();

}

// *** Restrict Access To Page: Grant or deny access to this page

$MM_restrictGoTo = "admin.php";

if (!isset($_SESSION['admin_loggedin'])) {  

    header("Location: ". $MM_restrictGoTo);

  exit;

}

/*

if (!isset($_SESSION['admin_loggedin'])) {  

  $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;

}

}

$addmerchantAction = $_SERVER['PHP_SELF'];

//echo $addmerchantAction;

//echo $addmerchantAction;

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

$MerchantID=$_POST['select_merchantid'];

  $RollingReserve=$_POST['txn_rlngreserve'];

$TDR=$_POST['txn_tdr'];

$CentreMoney=$_POST['txn_cntrmoney'];

$regdate=date('y-m-d');

$updateSQL ="UPDATE `merchant` SET `rolling_reserve`=$RollingReserve,`TDR`= $TDR,`merchant_money`=$CentreMoney WHERE `merchantid`='$MerchantID'" ;

                                        $Result1 = mysql_query($updateSQL, $conn) or die(mysql_error());

;

//redirect user to process page

$insertGoTo = "adminpanel.php";

header(sprintf("Location:%s", $insertGoTo));

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Merchant Details</title>

</head>

<body>

<div id="form" >

<form id="form1" name="form1" method="POST" action="<?php echo $addmerchantAction; ?>">

<table >

            <tr valign="top">

                <td>

                  <table >

                        <tr style="height: 30px; font-weight: bold;" valign="top">

                      <tr valign="top">

                            <td>Merchant ID</td>

                            <td>

       <select name="select_merchantid" class="selectMedium">

       <option value="text01">text01</option>

<?php

    $query="SELECT merchantid FROM merchant ORDER BY merchantid";

    $rs=mysql_query($query);

    while($row1=mysql_fetch_object($rs)){

?>

        <option value="<?php echo $row1->merchantid;?>"><?php echo $row1->merchantid;?> </option>

<?php

    }

?>

</select> <br />

                                <span id="RequiredFieldValidator13" style="color:Red;display:none;">CVV required</span>

                            </td>

                        </tr>

                        <tr valign="top">

                            <td>Rolling Reserve</td>

                            <td>

                                <input name="txn_rlngreserve" type="text"  id="txn_rlngreserve"  /><br />

                                <span id="rfvFirstName" style="color:Red;display:none;">First Name required</span>

                            </td>

                        </tr>

                        <tr valign="top">

                            <td>TDR</td>

                            <td>

                                <input name="txn_tdr" type="text"  id="txn_tdr"  /><br />

                                <span id="RequiredFieldValidator1" style="color:Red;display:none;">Last Name required</span>

                            </td>

                        </tr>

                        <tr valign="top">

                            <td>Centre Money</td>

                            <td>

                                <input name="txn_cntrmoney" type="text" id="txn_cntrmoney"  /><br />

                                <span id="RequiredFieldValidator1" style="color:Red;display:none;">Last Name required</span>

                            </td>

                         <tr>

                            <td colspan="2" align="right">

                              <div class="submit">

    <input type="hidden" name="MM_insert" value="form1" />

          <input type="submit" value="Add" />

    </div></td>

                        </tr>

                    </table>

                </td>

            </tr>

        </table>

        </form>

   </div>    

</body>

</html>

This topic has been closed for replies.
Correct answer Rob Hecker2

I didn't bother to read through the code you sent.

You cannot redirect using PHP (header(Location)) after anything has been sent to the browser, which includes anything echoed.

You can, however, use javascript:

<script type="text/javascript">

window.location = "<?=$url?>";

</script>

1 reply

Rob Hecker2
Rob Hecker2Correct answer
Legend
December 18, 2013

I didn't bother to read through the code you sent.

You cannot redirect using PHP (header(Location)) after anything has been sent to the browser, which includes anything echoed.

You can, however, use javascript:

<script type="text/javascript">

window.location = "<?=$url?>";

</script>

shoney33
shoney33Author
Participating Frequently
December 19, 2013

thank you very much..

It worked very well