Forum Moderators: coopster
<?php
$user="user";
$pass="pass";
$db="database_name";
$first_name=$_POST['first_name'];
$last_name =$_POST['last_name'];
$MRN=$_POST['MRN'];
$sex=$_POST['sex'];
$height=$_POST['height'];
$weight=$_POST['weight'];
$BSA=$_POST['BSA'];
$race=$_POST['race'];
$age=$_POST['age'];
$hospital=$_POST['hospital'];
$AMO=$_POST['AMO'];
$dxdate=$_POST['dxdate'];
$prior_chemo=$_POST['prior_chemo'];
$chemoline=$_POST['chemoline'];
$chemotype=$_POST['chemotype'];
$mets=$_POST['mets'];
$crc_trial=$_POST['crc_trial'];
$total_cycles=$_POST['total_cycles'];
$chemo_response=$_POST['chemo_response'];
$survival=$_POST['survival'];
$ecog=$_POST['ecog'];
$progress_time=$_POST['progress_time'];
$myelo_tox=$_POST['myelo_tox'];
$gastro_tox=$_POST['gastro_tox'];
$neuro_tox=$_POST['neuro_tox'];
// Connect to the database server
$dbcnx = @mysql_connect('localhost', 'username', 'password');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
// Select the patient database
if (!@mysql_select_db('db_url')) {
exit('<p>Unable to locate the CRC ' .
'database at this time.</p>');
}
$query = "INSERT INTO patient_information (patient_id, first_name, last_name, MRN, sex, height, weight, BSA, race, age, hospital, AMO, dxdate, prior_chemo, chemoline, chemotype, mets, crc_trial, total_cycles, chemo_response, survival, ecog, progress_time, myelo_tox, gastro_tox, neuro_tox) VALUES ('','$_POST[last_name]','$_POST[last_name]','$_POST[MRN]','$_POST[sex]','$_POST[height]','$_POST[weight]', '$_POST[BSA]', '$_POST[race]','$_POST[age]','$_POST[hospital]', '$POST_[AMO]', '$POST_[dxdate]', '$_POST[prior_chemo]', '$_POST[chemoline]', '$_POST[chemotype]', '$_POST[mets]', '$_POST[crc_trial]', '$_POST[total_cycles]', '$_POST[chemo_response]', '$_POST[survival]', '$_POST[ecog]', '$_POST[progress_time]', '$_POST[myelo_tox]', '$_POST[gastro_tox]', '$_POST[neuro_tox]')";
echo "success in database entry.";
echo "<br />";
echo "<a href=\"add_patient.html\">Click here to return to the form page.</a>";
mysql_close();
?>
I don't see anywhere that the query is actually sent to mysql.
after your
$query = "INSERT INTO patient_information...
you need to do a mysql_query like so
mysql_query($query) or die (mysql_error());
the second part will give you the actual error from mysql if there is a problem.
While we are looking at inserting user input values into a database, you need to do a little more "cleaning" on that user input.
testing to make sure the values from the forms are of the proper type and escaping the values for insertion into mysql.
take a look at mysql_real_escape_string() [php.net] as well as ctype functions [php.net]
Googling where I went wrong now...but any help is greatly appreciated!