I have a form from which the user inputs some data.
Now i need to check from the database whether these are valid values or not since the values inputted can clash with the existing values.
Here is the query:
Code: Select all
$sql="if exists(select * from EnvironmentBookingtest where EnvironmentId=$_POST[EnvName] and ((convert(varchar(10),convert( datetime,'$_POST[Date1]',103), 110 ) between StartDate and EndDate) OR (convert(varchar(10),convert( datetime,'$_POST[Date2]',103), 110 ) between StartDate and EndDate)))
begin
print 'wrong data'
end
else
begin
INSERT INTO EnvironmentBooking VALUES ($_POST[EnvName],'".$_POST[BookFor]."',convert(varchar(10),convert( datetime,'$_POST[Date1]',103), 110 ),convert(varchar(10),convert( datetime,'$_POST[Date2]',103), 110 ),'".$_POST[Purpose]."',getdate())
end";
sybase_query($sql) or die ('Error updating database');Or is there a way where i can add it as a validation using javascript such that it can be sent as an alert ??
Please help.Its urgently required.