• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

I try to send value form one page to ano ther page but it not work PHP

The code be low i trey to send value form one page to another page but it not work what wrong with it
<?php require_once('../Connections/village.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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;
}
}
 
 
$AccNo = $_POST['AccNo'];
 
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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;
}
}
 
mysql_select_db($database_village, $village);
$query_rec_borrowpay = "SELECT balanceborow.wid, balanceborow.wname, balanceborow.amout,  CEILING(balanceborow.amout*.02) AS Interrest, balanceborow.DateBalance, balanceborow.amout, Round(DATEDIFF( NOW() , balanceborow.DateBalance)/30, 0) As MonthNos, (Round(DATEDIFF( NOW() , balanceborow.DateBalance)/30, 0)*2-1)*CEILING(balanceborow.amout*.02) As MiniPay FROM balanceborow WHERE balanceborow.wid ='$AccNo'   ";
$rec_borrowpay = mysql_query($query_rec_borrowpay, $village) or die(mysql_error());
$row_rec_borrowpay = mysql_fetch_assoc($rec_borrowpay);
$totalRows_rec_borrowpay = mysql_num_rows($rec_borrowpay);
 
mysql_select_db($database_village, $village);
mysql_db_query($database_village,"SET NAMES tis620"); 
$query_Recordset1 = "SELECT listname.ID, listname.Name FROM listname WHERE listname.ID = '$AccNo' ";
$Recordset1 = mysql_query($query_Recordset1, $village) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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=tis-620" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
	font-size: xx-large;
	color: #000066;
}
-->
</style>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>
 
<body>
<form id="form1" name="form1" method="post" action="Village_paymentProcessing.php">
  <label></label>
  <h1>
    <label></label>
  </h1>
  <table width="531" height="189" border="1">
    <tr>
      <td width="167" height="47">ACCOUNT NO</td>
      <td width="348"><?php echo $row_rec_borrowpay['wid']; ?></td>
    </tr>
    <tr>
      <td height="49">ACCOUNT NAME</td>
      <td><?php echo $row_rec_borrowpay['wname']; ?></td>
    </tr>
    <tr>
      <td height="49">Interrest</td>
      <td><?php echo $row_rec_borrowpay['Interrest']; ?></td>
    </tr>
    <tr>
      <td height="49">Bowrow Amount</td>
      <td><?php echo $row_rec_borrowpay['amout']; ?> baht Date <?php echo $row_rec_borrowpay['DateBalance']; ?></td>
    </tr>
    <tr>
      <td height="49">No of month</td>
      <td><?php echo $row_rec_borrowpay['MonthNos']; ?></td>
    </tr>
    <tr>
      <td height="49">Minimum Payment</td>
      <td><h1 class="style1"><?php echo $row_rec_borrowpay['MiniPay']; ?></h1></td>
    </tr>
    <tr>
      <td>BAHT </td>
      <td><span id="sprytextfield1">
      <input name="payment" type="text" class="style1" id="textfield" />
      <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><label>
        <input type="submit" name="button" id="button" value="Submit" />      
        <input name="AccNo" type="hidden" value="<?php echo $row_rec_borrowpay['wid']; ?>" />
        <input name="MinimumPay" type="hidden" value="<?php echo $row_rec_borrowpay['MiniPay']; ?>" />
         <input name="NoOfMonth" type="hidden" value=" <?php echo $row_rec_borrowpay['MonthNos']; ?>" />
            <input name="Interrest" type="hidden" value=" <?php echo $row_rec_borrowpay['Interrest']; ?>" />
          <input name="Cancel" type="button" id="button2" value="cancel" onClick="history.go(-1)" />
      </label></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <label></label>
</form>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "integer", {validateOn:["change"]});
//-->
</script>
</body>
</html>
<?php
mysql_free_result($rec_borrowpay);
 
mysql_free_result($Recordset1);
?>
 
 
 
 
***********************************
 
Village_paymentProcessing.php
**********************************
 
 
 
<?php 
 
$AccNo = $_POST['AccNo'];
$MinimumPay = $_POST['MinimumPay'];
$payment = $_POST['payment'];
$NoOfMonth = $_POST['NoOfMonth'];
$Interrest = $_POST['Interrest'];
 
echo " $AccNo  $MinimumPay   $payment   " ;
 
?>

Open in new window

0
teera
Asked:
teera
  • 5
  • 2
  • 2
2 Solutions
 
AlexSoftware EngineerCommented:
when you say that it is not work what do you mean exactly?
For example when you echo the post vars nothing print?
Because if you mean this you make a mistake in the echo...

$AccNo = $_POST['AccNo'];
$MinimumPay = $_POST['MinimumPay'];
$payment = $_POST['payment'];
$NoOfMonth = $_POST['NoOfMonth'];
$Interrest = $_POST['Interrest'];
 
echo " $AccNo  $MinimumPay   $payment   " ;  <--- you can not put quotes around the php variables...

echo $AccNo;
echo "<br>";

echo $$MinimumPay;
echo "<br>";

echo $payment   ;
echo "<br>";

change the echo.
0
 
Cornelia YoderArtistCommented:
@alex_code:   >>>>>echo " $AccNo  $MinimumPay   $payment   " ;  <--- you can not put quotes around the php variables...

Sure you can, I do it all the time.
0
 
AlexSoftware EngineerCommented:
echo $AccNo;
echo "<br>";

echo $$MinimumPay; <-- sory i put by accident a  more... remove it
echo "<br>";

echo $payment;
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
AlexSoftware EngineerCommented:
yes you can but only if you open a tag <? inside of the quotes.Try to change the echo as i said and tell me if something changes...
0
 
Cornelia YoderArtistCommented:
Alex, the most common echo I use is

echo "varname=$varname<br>";  

It works just fine, that's NOT his problem.
0
 
AlexSoftware EngineerCommented:
ok i agree with you but i said it for security reasons to be sure that if the variable is not empty to echo something.

Ok let's see where is the problem

i try this:I put static text into the hiddens text fields,echo the data contais and it is working properly.I think that the vars of the database table you select comes empty.

All those If your problem is that nothing echo.You didn't tell me what kind of error you get.You get any warning?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
        font-size: xx-large;
        color: #000066;
}
-->
</style>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>
 
<body>
<form id="form1" name="form1" method="post" action="Village_paymentProcessing.php">
  <label></label>
  <h1>
    <label></label>
  </h1>
  <table width="531" height="189" border="1">
    <tr>
      <td width="167" height="47">ACCOUNT NO</td>
      <td width="348"><?php echo $row_rec_borrowpay['wid']; ?></td>
    </tr>
    <tr>
      <td height="49">ACCOUNT NAME</td>
      <td><?php echo $row_rec_borrowpay['wname']; ?></td>
    </tr>
    <tr>
      <td height="49">Interrest</td>
      <td><?php echo $row_rec_borrowpay['Interrest']; ?></td>
    </tr>
    <tr>
      <td height="49">Bowrow Amount</td>
      <td><?php echo $row_rec_borrowpay['amout']; ?> baht Date <?php echo $row_rec_borrowpay['DateBalance']; ?></td>
    </tr>
    <tr>
      <td height="49">No of month</td>
      <td><?php echo $row_rec_borrowpay['MonthNos']; ?></td>
    </tr>
    <tr>
      <td height="49">Minimum Payment</td>
      <td><h1 class="style1"><?php echo $row_rec_borrowpay['MiniPay']; ?></h1></td>
    </tr>
    <tr>
      <td>BAHT </td>
      <td><span id="sprytextfield1">
      <input name="payment" type="text" class="style1" id="textfield" />
      <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><label>
        <input type="submit" name="button" id="button" value="Submit" />
        <input name="AccNo" type="hidden" value="gfhhgfh" />
        <input name="MinimumPay" type="hidden" value="gfhfgh" />
         <input name="NoOfMonth" type="hidden" value="fghfghfg" />
            <input name="Interrest" type="hidden" value="fghfghfh" />
          <input name="Cancel" type="button" id="button2" value="cancel" onClick="history.go(-1)" />
      </label></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <label></label>
</form>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "integer", {validateOn:["change"]});
//-->
</script>
</body>
</html>
 
 
Village_paymentProcessing.php
**********************************
 
 
 
<?php 
 
$AccNo = $_POST['AccNo'];
$MinimumPay = $_POST['MinimumPay'];
$payment = $_POST['payment'];
$NoOfMonth = $_POST['NoOfMonth'];
$Interrest = $_POST['Interrest'];
 
echo " $AccNo  $MinimumPay   $payment   " ;
 
?>

Open in new window

0
 
teeraAuthor Commented:
It still nothing print  Does It have more thing not correct in my code


<?php

$AccNo = $_POST['AccNo'];
$MinimumPay = $_POST['MinimumPay'];
$payment = $_POST['payment'];
$NoOfMonth = $_POST['NoOfMonth'];
$Interrest = $_POST['Interrest'];

echo $AccNo;
echo "<br>";

echo $MinimumPay;
echo "<br>";

echo $payment   ;
echo "<br>";

?>
0
 
AlexSoftware EngineerCommented:
As i see to your code you don't use any extract data with a while statement.How do you get the table data?
0
 
teeraAuthor Commented:
That page can get data form database I capture  picture when I run it
ask.JPG
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now