0
PHP에서 업데이트하는 데 문제가 없지만 코드를 입력해도 금액이 입력 되어도 테이블과 데이터베이스에서 업데이트되지 않습니다. 그런데 이전 프로그램에서 일부 코드를 가져 와서 일부 가변 코드가 적절하지 않을 수 있습니다. 고맙습니다. 당신이이 일을삽입 업데이트가 테이블과 데이터베이스에서 업데이트되지 않습니다.
반향을 반향 할 필요가
load.php
<form method="POST" action="process-load.php">
<?php
require_once('connect/connect.php');
$id = mysql_escape_string($_GET['id']);
$sql = 'SELECT * FROM cards WHERE id='.$id.' LIMIT 0, 1';
$qry = mysql_query($sql);
$data = mysql_fetch_array($qry);
$html = '';
$html .= '<div class="box">';
$html .= '<b> Card #: '.$data['cardno'].'</b><br />';
$html .= '<b>Current Balance: </b>'.$data['balance'].'<br />';
$html .= '<b>Enter Addition Load: </b><input type="text" name="load" size="5" /><br />';
$html .= '<input type="hidden" value="'.$_GET['id'].'" name="id" />';
$html .= '<input type="hidden" value="'.$data['balance'].'" name="bal" />';
$html .= '<input type="submit" value="Submit" name="submit" />';
$html .= '</div>';
echo $html;
?>
</form>
프로세스 load.php
<?php
session_start(); //don't forget to start session or else session will not be red
if(isset($_POST['submit'])) {
require_once('connect/connect.php');
$id = mysql_escape_string($_POST['id']);
$bal = $_POST['bal'];
$load = $_POST['load'];
$select_sql = 'SELECT balance FROM cards WHERE id="'.$id.'" LIMIT 0, 1';
$qry = mysql_query($select_sql);
$data = mysql_fetch_array($qry);
$new_bal = $data['balance'] + $bal;
$sql_update = 'UPDATE cards SET balance="'.mysql_escape_string($new_bal).'" WHERE id="'.$id.'"';
$qry2 = mysql_query($sql_update);
$bill = $bal += $load;
$_SESSION['profit'] += $bill; //add total bill always to your session
if($qry2) {
?>
<script>
alert('Thank you.\n New Balance: <?php echo $bill; ?>');
window.location.href = 'index.php?page=show';
</script>
<?php
} else {
?>
<script>
alert('Failed to load card.';);
window.location.href = 'index.php?page=show';
</script>
<?php
}
mysql_close($con);
}
?>
중요한 부분에 다음 코드를 넣으십시오 :'echo''part1'':'echo $ select_sql. "<- sql";':'echo $ qry. "<- qry";':'echo $ new_bal. "<-newbal"; 등. 그리고 출력을 보여줘. –