PDA

View Full Version : how to get the value????


tanhaha_how
01-13-2007, 04:38 PM
hi,i jz want to ask how to get the value with diff page....


include 'connStr.php';

$query ="";

if ($_POST["actionMode"]=="Create"){

$upperSex = strtoupper($_POST["Sex"]);

$query = "Insert into tblpatient('', Treatment_Date, Name, Sex, ICNO, Age, DOB, Address, Postcode, Race, Language_Spoken, Telephone_house, Telephone_office, Handphone, Allergy, Email)values('".$_POST["Patient_ID"]."', '".$date1."', '".$_POST["nam"]."', '".$upperSex."', '".$_POST["ICNO"]."', '".$_POST["Age"]."', '".$date."', '".$_POST["Address"]."', '".$_POST["Postcode"]."', '".$_POST["Race"]."', '".$_POST["Language_Spoken"]."', '".$_POST["Telephone_house"]."', '".$_POST["Telephone_office"]."', '".$_POST["Handphone"]."', '".$_POST["Allergy"]."', '".$_POST["Email"]."');";

$result = mysql_query($query);

$patientID = mysql_insert_id()

mysql_query("COMMIT");
}

echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">";

echo "<meta http-equiv=\"REFRESH\" content=\"0; URL=patientRecords.php\">";


in another form,how to get this $patientID???
actually i want to display the auto_increment value....but dunno y cant get the next patient ID.....help me pls...

thanks a lot:)

Linark
01-13-2007, 06:22 PM
What errors are you receiving?

marf
01-13-2007, 07:38 PM
If I'm guessing your problem correctly, you could make a Cookie that stores their patient ID, however thats easily exploited by the user if you want this to be secure, perhaps giving them a Session.

look up session() on php's function list it may help for what your talking about.

tanhaha_how
01-14-2007, 03:35 AM
What errors are you receiving?

actually what i showed u the code is insert_patientRecords.php....however,i have another page name new_patientRecords.php which is a form to let patient fill in their particulars....

(new_patientRecords.php)

<?php
$query = "Select * from tblpatient order by Patient_ID desc limit 1";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);

$newPatientID = $row["Patient_ID"] + 1;
?>
<form name="form" action="insert_patientRecords.php" method="POST" onSubmit=" return validate(this)">

<td width="108" align="left" valign="Middle">Patient ID:</td>

<td width="173" align="Left" valign="Middle">
<input type="text" readonly="yes" size="10" maxlength="5" name="Patient_ID" style="font-size:10px; font-family:Verdana; width:40px;" value="<?php echo $newPatientID; ?>"></td>


(insert_patientRecords.php)

include 'connStr.php';

$query ="";

if ($_POST["actionMode"]=="Create"){

$upperSex = strtoupper($_POST["Sex"]);

$query = "Insert into tblpatient('', Treatment_Date, Name, Sex, ICNO, Age, DOB, Address, Postcode, Race, Language_Spoken, Telephone_house, Telephone_office, Handphone, Allergy, Email)values('".$_POST["Patient_ID"]."', '".$date1."', '".$_POST["nam"]."', '".$upperSex."', '".$_POST["ICNO"]."', '".$_POST["Age"]."', '".$date."', '".$_POST["Address"]."', '".$_POST["Postcode"]."', '".$_POST["Race"]."', '".$_POST["Language_Spoken"]."', '".$_POST["Telephone_house"]."', '".$_POST["Telephone_office"]."', '".$_POST["Handphone"]."', '".$_POST["Allergy"]."', '".$_POST["Email"]."');";

$result = mysql_query($query);

$patientID = mysql_insert_id()

mysql_query("COMMIT");
}

echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">";

echo "<meta http-equiv=\"REFRESH\" content=\"0; URL=patientRecords.php\">";


coz i need to display the next ID(last insert ID + 1) inside the textbox.....but i hav tried session before....but dunno y i cant get the correct value...when the last record ID is 10....but the value display inside the textbox still remain 1...but if i use $newPatientID = $row["Patient_ID"] + 1;,what the ID display inside the textbox is diff with the ID stored inside the database....help me pls....thanks...

tanhaha_how
01-15-2007, 04:14 AM
hi everyone...i hav show all the codes above...but dunno y i jz cant get the value....can u all pls help me????

thanks a lot....:o