...

View Full Version : Resolved PHP unable to submit



grayfoxmy
04-28-2011, 04:34 PM
I have problem which unable to submit the php script, anyone pls help? Thank You

<?
//bugged
session_start();
include "DbConnection.php";
include "convert.php";
import_request_variables("GP","v");
$vbookingNumber=$_GET['bookingNumber'];
$hiddentime=$_GET['hiddentime'];
$sessionStaffId=$_SESSION['staffId'];
$query = "SELECT * FROM staff WHERE staffID ='$sessionStaffId'";
$queryResult=mysql_query($query);
$count=mysql_num_rows($queryResult);
while($info = mysql_fetch_array($queryResult))
{
$hospitalId=$info['hospitalId'];
}

if($count>0)
{
$selectFromBookingNo="SELECT * FROM bookings,patient,hospital,radiology_code,gp,room
WHERE bookings.patientId=patient.patientId and
bookings.roomId=room.roomId and
bookings.radiology_code_id=radiology_code.radiology_code_id and
hospital.hospitalId=room.hospitalId and
gp.gpId=bookings.gpId and
bookingId='$vbookingNumber'";
$querySelectFromBookingNo=mysql_query($selectFromBookingNo);
while($info2 = mysql_fetch_array($querySelectFromBookingNo))
{
$patientFName=$info2['patientFName'];
$patientLName=$info2['patientLName'];
$patientTitle=$info2['patientTitle'];
$patientDOB=$info2['patientDOB'];
$patientAdd=$info2['patientAdd'];
$patientEmail=$info2['patientEmail'];
$patient_home_num=$info2['patient_home_num'];
$patient_mobile_num=$info2['patient_mobile_num'];
$gpFName=$info2['gpFName'];
$gpLName=$info2['gpLName'];
$gpPhone=$info2['gpPhone'];
$gpEmail=$info2['gpEmail'];
$radiology_code_id=$info2['radiology_code_id'];
$radiology_code_desc=$info2['radiology_code_desc'];
$roomLocation=$info2['room.roomLocation'];
$bookingtime=$info2['bookingtime'];
$bookingnotes=$info2['bookingnotes'];
$hospitalId=$info2['hospitalId'];
$hospitalName=$info2['hospitalName'];
}
?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<title>Edit Booking</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>Edit User Booking Page</h1>
<form name='f1' action="EditBooking.php" >
<script>
function submitForms()
{
var a=document.forms[0].elements["hiddenvalue"];
if (confirm("\n You are about to Save & Print your submission. \n\nOK to submit. Cancel to abort."))
{
a.value=1;
return true;
}
else
{
a.value=0;
alert("\n You have chosen to abort the submission.");
//console.log("\n You have chosen to abort the submission."); optional cause not every browser support alert
return false;
}
}
function clearValue()
{
document.getElementById('AnotherDate').value="";
document.getElementById('hiddentime').value="";
document.f1.AnotherDate.value='';
}
function makeDisable()
{
var x=document.getElementById("hospitalid");
x.disabled=true;
}
function testing()
{
var a= document.getElementById('AnotherDate').value;
var b = document.getElementById('hospitalid').value;
if (a!="" && b!="")
{
makeDisable();
window.open ("schedule.php?date="+a+"&hospitalId="+b, "mywindow","location=1,status=1,scrollbars=1, left=120,top=120,width=500,height=500,toolbar=1,resizable=0");
}
else
{
alert("Please Select the Date First!");
}
}
function reset()
{
var x=document.getElementById("hospitalid");
x.disabled=false;
clearValue();
}
</script>
<script type="text/javascript" src="datePicker.js"></script>
<?
include 'datepicker.css';
echo "<table align='center'>
<tr><td>Patient Name: </td><td>$patientTitle $patientLName $patientFName</td></tr>
<tr><td>Date of Birth: </td><td>$patientDOB</td></tr>
<tr><td>Patient Address: </td><td>$patientAdd</td></tr>
<tr><td>Patient Email: </td><td>$patientEmail</td></tr>
<tr><td>Patient Contact Number: </td><td> Home: $patient_home_num &nbsp Mobile: $patient_mobile_num</td></tr>
<tr><td>GP Name: </td><td> Dr $gpLName $gpFName</td></tr>
<tr><td>GP Phone: </td><td> $gpPhone</td></tr>
<tr><td>GP Email: </td><td> $gpEmail</td></tr>
<tr><td>Radiology code/Desc: </td><td>$radiology_code_id/$radiology_code_desc</td></tr>
<tr><td>Booking notes: </td><td>$bookingnotes</td></tr>

<tr><td>Booking Time: </td><td>Originally <SPAN style='BACKGROUND-COLOR: #ffff00'>"; echo ConvertTime($bookingtime); echo " ".ConvertDate($bookingtime);
echo "</SPAN> <br> New: ";?>
<input name='AnotherDate' id='AnotherDate' onclick="displayDatePicker('AnotherDate', false, 'ymd', '-');clearValue();" value='<?=$vDate?>' readonly>
<input type="button" value="Search" onclick="testing();">
</td></tr><?

echo "
<tr><td>Change hospital: </td><td><select name='hospital' id='hospitalid' value='1'>";
$queryHos="select * from hospital where hospitalId!=$hospitalId";
if($resultHos=mysql_query($queryHos))
{
echo "<option selected value='$hospitalId'>$hospitalName</option>";
for($j=0;$j<mysql_num_rows($resultHos);$j++)
{
$hospitalId = mysql_result($resultHos,$j, "hospitalId");
$hospitalName = mysql_result($resultHos,$j, "hospitalName");
echo "<option value='$hospitalId' ";
if($_POST["hospital"] == $hospitalId)
{
echo "selected='selected' ";
}
echo ">$hospitalName</option>";
}
}
else
{
echo "<option selected value=''>There Are no hospital available</option>";
}
?>
</td></tr>
<tr><td colspan='2' align='center'><input type="submit" value="Insert" name="btnInsert" onclick="submitForms();">
&nbsp&nbsp&nbsp
<input type='button' value='Reset' onclick='reset()'><input type='hidden' name='hiddentime' value='<?=$hiddentime?>' id='hiddentime' readonly>
<input type='hidden' name='bookingNumber' value='<?=$vbookingNumber?>' readonly><input type='text' name='hiddenvalue'>
</td></tr>
</table>
<?
if($_POST['btnInsert']=="Insert" && $_POST['hiddenvalue']==1)//or either isset($_POST['btnInsert']) also not working,here is the bug
{
list($roomId,$time,$date) = split('[,]', $hiddentime);
$convertedtimeDate= $date." ".ConvertInternationalTime($time);
echo $Update="UPDATE bookings,room SET bookingtime='$convertedtimeDate',bookings.roomId='$roomId' where bookingId='$vbookingNumber' ";
//mysql_query($Update);
echo "<script>alert('You have successfully update the Data!');</script>";
}?>
</form>
</body>
</html>

<?

}
?>

Fou-Lu
04-28-2011, 06:15 PM
You have this marked as resolved, but have not indicated any type of resolution so I don't know if you actually have it working.
Unable to submit completely would fall against the browser, and the JS in use. Never write a script or form in PHP that relies on the use of JS; always add JS after the fact to simplify. The easiest way to check and see if the fault is of the JS would be to submit a form with JS disabled to see if the post values are sent. This form itself will actually have a problem since even when you do submit the method is undefined for the form, so it will default to GET not POST. Add a method="post" to the form.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum