我很难解决这个问题。尝试了一切,但似乎无济于事。我什至有两个相似的页面,其他的插入和更新也很好,但这使我无法入睡。
填写表单条目并提交后,将确认已添加记录,但未将任何内容插入数据库表。这应该是诊所处理产假/ anc / pnc应用程序的一部分,但此问题仅影响anc文件。它的pnc部分效果很好。
我敢肯定,你们可以帮助我准确地了解我做错了什么,我将非常感谢您的帮助。对还是错。
首先,这是应该插入记录的文件,名为submitanc.php:
@$cid= $_POST["cid"];
@$card= $_POST["card"];
@$date= $_POST["date"];
@$doctor= $_POST["doctor"];
@$riskfactor= $_POST["riskfactor"];
@$cycle= $_POST["cycle"];
@$lmp= $_POST["lmp"];
@$edd= $_POST["edd"];
@$gestationage= $_POST["gestationage"];
@$visit= $_POST["visit"];
@$parity= $_POST["parity"];
@$bp= $_POST["bp"];
@$height= $_POST["height"];
@$weight= $_POST["weight"];
@$gestation= $_POST["gestation"];
@$fhh= $_POST["fhh"];
@$sickling= $_POST["sickling"];
@$hb= $_POST["hb"];
@$hb36wk= $_POST["hb36wk"];
@$vdll= $_POST["vdll"];
@$pmtct= $_POST["pmtct"];
@$arv= $_POST["arv"];
@$tt= $_POST["tt"];
@$itw= $_POST["itw"];
@$ipt= $_POST["ipt"];
@$referredto= $_POST["referredto"];
@$diagnosis= $_POST["diagnosis"];
@$remark= $_POST["remark"];
require_once 'conn.php';
if (isset($_POST['submit']))
{
switch ($_POST['submit'])
{
case 'Add Record':
if (Trim($card) != "" and Trim($date) != "")
{
$query_insert = "Insert into `anc` (`Card Number`, `Date`, `Physician`, `Risk Factor`, `Cycle`, `LMP`, `Edd`, `Gestation Age`, `Visit`, `Parity`, `BP`, `Height`, `Weight`, `Gestation`, `FHH`, `Sickling`, `HB@Reg`, `Temp`, `VDLL`, `PMTCT`, `ARV`,`TT`,`IPT`,`ITW`,`Referred To`,`Diagnosis` `Remark`,`SFH`,`HIV`,`Hep B`,`PH`,`Urine`,`Presentation`,`Lie`)
VALUES ('$card', '$date', '$doctor', '$riskfactor', '$cycle', '$lmp', '$edd', '$gestationage', '$visit', '$parity', '$bp', '$height', '$weight', '$gestation', '$fhh', '$sickling', '$hb', '$temp', '$vdll', '$pmtct', '$arv','$tt','$ipt','$itw','$referredto','$diagnosis', '$remark','$sfh','$hiv','$hepb','$ph','$urine','$presentation','$lie')"; $result_insert = mysql_query($query_insert);
在这里,我知道它很疯狂,但这是表单页面,称为anc.php:
<form action="submitanc.php" method="post">
<fieldset id="fieldset">
<legend><b><font size="2" face="Tahoma" color="green">Ante-Natal Basics</font></b></legend>
<div align="left">
<TABLE width='99%' border='0' cellpadding='1' cellspacing='1' align='center' bordercolor="#005B00" id="">
<tr>
<td width="20%">
<b><font face="Verdana" style="font-size: 9pt">Date of Visit:</font></b>
</td>
<td>
<input type="hidden" size="20" name="card" value="<?php echo $card; ?>">
<input type="hidden" size="20" name="cid" value="<?php echo $idx; ?>">
<?php
if (!$idx)
{ ?>
<input id="inputField" type="text" size="20" name="date" value="<?php echo date('Y-m-d'); ?>">
<?php
} else
{ ?>
<input id="inputField" type="text" size="20" name="date" value="<?php echo $srow['Date']; ?>">
<?php } ?>
</td>
<td width="20%">
<b><font face="Verdana" style="font-size: 9pt">Name of Doctor/Midwife:</font></b>
</td>
<td>
<input type="text" size="20" name="doctor" value="<?php echo $srow['Physician']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Major Risk Factor:</font></b>
</td>
<td colspan='3'>
<textarea cols="40" rows="3" name="riskfactor"><?php echo $srow['Risk Factor']; ?></textarea>
</td>
</tr>
</table>
</fieldset>
<fieldset id="fieldset">
<legend><b><font size="2" face="Tahoma" color="green">Menstrual History</font></b></legend>
<div align="left">
<TABLE width='99%' border='0' cellpadding='1' cellspacing='1' align='center' bordercolor="#005B00" id="">
<tr>
<td width="20%">
<b><font face="Verdana" style="font-size: 9pt">Cycle:</font></b>
</td>
<td>
<input type="text" size="20" name="cycle" value="<?php echo $srow['Cycle']; ?>">
</td>
<td width="20%">
<b><font face="Verdana" style="font-size: 9pt">Last Mentrual Period (L.M.P):</font></b>
</td>
<td>
<input type="text" size="20" name="lmp" value="<?php echo $srow['LMP']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Expected Delivery Date (E.D.D):</font></b>
</td>
<td>
<input type="text" size="20" name="edd" value="<?php echo $srow['EDD']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Gestation Age at Booking:</font></b>
</td>
<td>
<input type="text" size="20" name="gestationage" value="<?php echo $srow['Gestation Age']; ?>">
</td>
</tr>
</TABLE>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#dcdfdf" width="100%" id="AutoNumber1">
<?php
echo "<TR bgcolor='#9ff4ae'><TH><b><u>LMP </b></u> </TH><TH><b><u>EDD </b></u> </TH><TH><b><u>EGA to Date</b></u> </TH></TR>";
$querya="SELECT `ID`,`Card Number`,`Date`,`LMP`,`EDD`,`Gestation Age` FROM `anc` WHERE `Card Number`='$card' order by `Date` desc";
$resulta=mysql_query($querya);
while(list($idx,$cart,$date,$lmp,$edd,$ega)=mysql_fetch_row($resulta))
{
echo "<TR><TH><a title='Click on this to amend it' href = 'anc.php?idx=" . $idx . "&card=" . $cart . "&dat=" . $date . "'>$lmp </a> </TH><TH> $edd </TH><TH>$ega </font></TH></TR>";
}
?>
</table>
</fieldset>
<fieldset id="fieldset">
<legend><b><font size="2" face="Tahoma" color="green">Ante-Natal Examination</font></b></legend>
<div align="left">
<TABLE width='99%' border='0' cellpadding='1' cellspacing='1' align='center' bordercolor="#005B00" id="">
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Blood Pressure:</font></b>
</td>
<td>
<input type="text" size="20" name="bp" value="<?php echo $srow['BP']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Parity:</font></b>
</td>
<td>
<input type="text" size="20" name="parity" value="<?php echo $srow['Parity']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Weight:</font></b>
</td>
<td>
<input type="text" size="20" name="weight" value="<?php echo $srow['Weight']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Temperature:</font></b>
</td>
<td>
<input type="text" size="20" name="temp" value="<?php echo $srow['Temp']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Visit:</font></b>
</td>
<td>
<select size="1" name="visit">
<?php
echo '<option selected>' . $srow['Visit'] . '</option>';
echo '<option>New Visit</option>';
echo '<option>Returning Visit</option>';
?>
</select>
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Height:</font></b>
</td>
<td>
<input type="text" size="20" name="height" value="<?php echo $srow['Height']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Gestational Age:</font></b>
</td>
<td>
<input type="text" size="20" name="gestation" value="<?php echo $srow['Gestation']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">SFH:</font></b>
</td>
<td>
<input type="text" size="20" name="sfh" value="<?php echo $srow['SFH']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Sickling:</font></b>
</td>
<td>
<input type="text" size="20" name="sickling" value="<?php echo $srow['Sickling']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Hb:</font></b>
</td>
<td>
<input type="text" size="20" name="hb" value="<?php echo $srow['HB@Reg']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">HIV:</font></b>
</td>
<td>
<input type="text" size="20" name="hiv" value="<?php echo $srow['HIV']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Hep B:</font></b>
</td>
<td>
<input type="text" size="20" name="hepb" value="<?php echo $srow['HepB']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">PH:</font></b>
</td>
<td>
<input type="text" size="20" name="ph" value="<?php echo $srow['PH']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Urine:</font></b>
</td>
<td>
<input type="text" size="20" name="urine" value="<?php echo $srow['Urine']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Presentation:</font></b>
</td>
<td>
<input type="text" size="20" name="presentation" value="<?php echo $srow['Presentation']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Lie:</font></b>
</td>
<td>
<input type="text" size="20" name="lie" value="<?php echo $srow['Lie']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">FHR:</font></b>
</td>
<td>
<input type="text" size="20" name="fhh" value="<?php echo $srow['FHH']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">Sickling:</font></b>
</td>
<td>
<input type="text" size="20" name="sickling" value="<?php echo $srow['Sickling']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">VDLL:</font></b>
</td>
<td>
<input type="text" size="20" name="vdll" value="<?php echo $srow['VDLL']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">PMTCT:</font></b>
</td>
<td>
<?php
$sqlv2 = "SELECT `val`,`type` FROM `booln` ORDER BY `type` desc";
$result_v2 = mysql_query($sqlv2,$conn) or die('Could not list; ' . mysql_error());
$v2=$srow['PMTCT'];
while ($rows = mysql_fetch_array($result_v2))
{
echo ' <input type="radio" class="radio" align="left" id="v2_' . $rows['val'] . '" name="pmtct" value="' . $rows['val'] . '" ';
if ($rows['val'] == $v2)
{
echo 'checked="checked" ';
}
echo '/>' . $rows['type'] . "\n";
}
?>
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">ARV:</font></b>
</td>
<td>
<input type="text" size="20" name="arv" value="<?php echo $srow['ARV']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">TT:</font></b>
</td>
<td>
<input type="text" size="20" name="tt" value="<?php echo $srow['TT']; ?>">
</td>
</tr>
<tr>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">ITW:</font></b>
</td>
<td>
<input type="text" size="20" name="itw" value="<?php echo $srow['ITW']; ?>">
</td>
<td width="10%">
<b><font face="Verdana" style="font-size: 9pt">IPT:</font></b>
</td>
<td>
<?php
$sqlv2 = "SELECT `val`,`type` FROM `booln` ORDER BY `type` desc";
$result_v2 = mysql_query($sqlv2,$conn) or die('Could not list; ' . mysql_error());
$v2=$srow['IPT'];
while ($rows = mysql_fetch_array($result_v2))
{
echo ' <input type="radio" class="radio" align="left" id="v2_' . $rows['val'] . '" name="ipt" value="' . $rows['val'] . '" ';
if ($rows['val'] == $v2)
{
echo 'checked="checked" ';
}
echo '/>' . $rows['type'] . "\n";
}
?>
</td>
</tr>
<tr>
<td width="15%">
<b><font face="Verdana" style="font-size: 9pt">Refered To:</font></b>
</td>
<td>
<input type="text" size="20" name="referredto" value="<?php echo $srow['Referred To']; ?>">
</td>
<td width="15%">
<b><font face="Verdana" style="font-size: 9pt">Diagnosis:</font></b>
</td>
<td>
<input type="text" size="20" name="diagnosis" value="<?php echo $srow['Diagnosis']; ?>">
</td>
</tr>
<tr>
<td width="14%">
<b><font face="Verdana" style="font-size: 9pt">Remark:</font></b>
</td>
<td colspan='3'>
<textarea cols="40" rows="3" name="remark"><?php echo $srow['Remark']; ?></textarea>
</td>
</tr>
<tr>
<td width="10%">
<?php
if (!$idx)
{ ?>
<input type="submit" value="Add Record" name="submit">
<?php
} else
{ ?>
<input type="submit" value="Update Record" name="submit">
<?php } ?>
</td>
</tr>
</TABLE>
</form>
</fieldset>
<fieldset style="padding: 2">
<legend><b><font size="2" face="Tahoma" color="green">History of ANC</font></b></legend>
<b><font color="#FF0000" style="font-size: 8pt"><?php echo $tval ; ?></font></b>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#dcdfdf" width="99%" id="AutoNumber1">
<?php
echo "<TR bgcolor='#9ff4ae'><TH><b><u>Date of Visit </b></u> </TH><TH><b><u>Weight </b></u> </TH><TH><b><u>BP</b></u> </TH><TH><b><u>SFH </b></u> </TH><TH><b><u>Urine </b></u> </TH><TH><b><u>FHR </b></u> </TH></TR>";
$query="SELECT `ID`,`Card Number`,`Date`,`Weight`,`BP`,`SFH`,`Urine`,`FHR` FROM `anc` WHERE `Card Number`='$card' order by `Date` desc";
$result=mysql_query($query);
while(list($idx,$cart,$date,$wt,$bp,$sfh,$urine,$fhr)=mysql_fetch_row($result))
{
echo "<TR><TH><a title='Click on this to amend it' href = 'anc.php?idx=" . $idx . "&card=" . $cart . "&dat=" . $date . "'>$date </a> </TH><TH> $wt </TH><TH>$bp </font></TH><TH>$sfh </TH><TH>$urine </TH><TH>$fhr </TH></TR>";
}
?>
</table>
</fieldset>
最佳答案
更好用
mysql_escape_string($_POST['fieldname']);
并回显该查询并签入
mysql