Tuesday, 12 December 2017

Multiple Submit Buttons

Hi All,
Please see the code.

<html>
<body>
<form method=post>
Number1 <input type=text name=num1>
Number2 <input type=text name=num2>
<input type=submit value='Add' name=btnadd>
<input type=submit value='Sub' name=btnsub>
</form>
<?php
if(isset($_POST['num1']))
{
$n1=$_POST['num1'];
$n2=$_POST['num2'];
if(isset($_POST['btnadd']))
{
$sum=$n1+$n2;
echo "Sum is ".$sum;
}
else if(isset($_POST['btnsub']))
{
$diff=$n1-$n2;
echo "Difference is ".$diff;
}

}//IF ends
?>
   
</body>
</html>

Friday, 20 October 2017

Load one Combo based on another combo without Ajax

HI All,
Find this code


<!DOCTYPE html>
<!-- Website template by freewebsitetemplates.com -->
<html>
<head>
 <meta charset="UTF-8">
 <title>Services - Medical Hospital Website Template</title>
 <link rel="stylesheet" href="css/style.css" type="text/css">
 <script>
function loadDoc() {
document.frmsearch.action='#';
document.frmsearch.submit();
//alert('HUP');
/*
     var key=document.frmsearch.pps.value;
      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
             document.getElementById("demo").innerHTML = xhttp.responseText;
        }
  };
  xhttp.open("GET", "searchdoctor.php?key="+key, true);
  xhttp.send();
  */
}
function assign()
{
 alert('HUP');
}
</script>

</head>
<body>
 <div class="background">
  <div class="page">
   <a href="index.html" id="logo">Hospital management with patient disease prediction</a>
   <div class="sidebar">
    <ul>
     <li>
      <a href="index.php">Back</a>
     </li>
    <div class="first">

      <p>
        <br> <?php
include"patientmenu.php"
?>     <div>
                 </p>
     </div>
    </div>
    <div>

      <p>
      
      </p>
      <img src="images/doctors-and-nurse.jpg" alt="">
      <p>
             </p>
     </div>
    </div>
   </div>
   <div class="body">
    <div class="services">
     <div>
     <center> <b> PATIENT DETAILS</b></center>
<body>
<?php
 include('dbconnect.php');
$data=mysql_query("select max(id) as mid from appointment");
$row=mysql_fetch_array($data);
$did=$row['mid']+1;
?>
<?php
if(isset($_POST['pps']))
{
echo "entered";
$sname=$_POST['pps'];
$sql="Select doctorname from doctorreg where specialization like '%$sname%'";

$data=mysql_query($sql,$con);
$str= "<select name=pcd >";
while($row=mysql_fetch_array($data))
{
$name=$row['doctorname'];
$str=$str. "<option value='$name'>$name</option>";
}
$str=$str. "</select>";
mysql_close($con);
$str1="<option value='$sname'>$sname</option>";
}
else
{
 $str="";
 $str1="<option value='selected'>--Select--</option>";
}
?>
<form name=frmsearch action=appoinsert.php method=post enctype="multipart/form-data"><table align=center>
<tr>
<td width="168">   Id</td>
    <td>:</td>
    <td width="255"><?php echo $did ?>
        <input type=hidden name="pid" value="<?php echo $did ?>"></td>
  <tr><td>Specialization:</td><td><select name=pps onChange="loadDoc()"><?php echo $str1; ?><option value='cardiology'>Cardiology</option><option value='ENT'>ENT</option> </select></td></tr>
<tr><td>Consulting Doctor name:</td><td><?php echo $str; ?></td></tr>
<tr><td>Patient Name:</td><td><input type="text"name="pname""required="required"></td></tr>
<tr><td>Address :</td><td><input type="text"name="pad" pattern"[a-z,A-Z]{1,10} required="required"></td></tr>
<tr><td>ContactNo:</td><td><input type="text"name="pdd" required="required"></td></tr>
<tr><td>Date:</td><td><input type="date"name="prn" required="required"></td></tr>
<tr><td>Time:</td><td><input type="time" name="pad" required="required"></td><tr>
 <tr><td colspan=2 align=center><input type="submit" value='Submit'></td></tr>
<tr><td colspan=2 align=center><input type=reset value='Clear'></td></tr></table>
</form><div>
       <div>
                 <img src="images/services2.jpg"alt="">
        

Saturday, 29 April 2017

Validation for Email, text only, numbers only

Dear All,

See the code

-----------------------------------------------------------------------------------------------------------

<center>
<br><br>
<font color=BLACK>LOGIN   
<script>

function check()
{
    username=document.frm.username.value;
    password=document.frm.password.value;
    if(username=="")
    {
        alert('Enter username');
        document.frm.username.focus();
        return false;
    }
    else if (!/^[a-zA-Z]*$/g.test(username))//Ony a-z characters
     {
        alert("Invalid characters");
        document.frm.username.value='';
        document.frm.username.focus();
        return false;
    }
    else if(!/\S+@\S+\.\S+/.test(password))//Only Email
    {
        alert('Enter email in password');
        document.frm.password.value='';
        document.frm.password.focus();
        return false;
    }
    else if(isNaN(password))//Only numbers
    {
        alert('Enter number in password');
        document.frm.password.value='';
        document.frm.password.focus();
        return false;
    }
   
   
    return true;

   
}
</script>
<form name=frm action="logincheck.php" method=post onsubmit='return check()'>   
<table cellpadding=5>
<form action="logincheck.php" method=post>
<tr><td>USER NAME :<td><input type=text name=username><br>
<tr><td>PASSWORD  :<td><input type=text name=password>
</table>
<input type=submit value=submit>
</form>

Wednesday, 2 November 2016

Form with rounded Border

Hi All,

See this code to put rounded border to forms.

---------------------------------------------------------------------
<html>
<head>
<style>
fieldset {
  -moz-border-radius:5px;
  border-radius: 5px;
  -webkit-border-radius: 5px; //edit :D
 
}
</style>
</head>
<body>
<fieldset  style="width:250px">
<form action=HUPModify.php method=post>
<pre>
New Reference Number <input name=nrefno>
Total References     <input name=tref>
<input type=submit value="Change file">
</pre>
</form>
</fieldset>
</body>
</html>

---------------------------------------------------------------------

Sunday, 30 October 2016

Hi All,

If you want to find the difference between two dates (Eg. current date and another date) use this simple code

<?php

$current = time(); // Current date and time
$testdate= strtotime("2016-10-20");
$daydiff = $current - $testdate;
echo floor($daydiff / (60 * 60 * 24));

?>

Using this code you can find the fine by calculating day difference between current date and book issue date.

Saturday, 11 June 2016

Execute a Java program from PHP

Dear friends,

In data mining works we usually used to call java class files. Sometimes from PHP.

Try this code to invoke a Java program or some other jar executables from your PHP

Sample 1.

<?php

exec("java Apriori hup.dat 0.4 > hupa.txt");

?>

The above code will run Apriory.class with hup.dat as input file and the output will be saved in hupa.txt which can be further processed by PHP data mining program.

Sample 2.

<?php

exec("java -jar LDA/jar/jLDADMM.jar -model LDA -corpus LDA/test/corpus.txt -name testLDA -ntopics 5 -twords 5 > huplda.txt");

?>

The above code will run a jar file for LDA topic modeling algorithm stored in LDA/jar/ folder in www directory of LAMP or WAMP or XAMPP with lot of switches and output can be redirected to huplda.txt file.

Show Time difference in milliseconds using PHP

Dear Friends,
We might have come across showing results by google with search time. The same can be implemented in our program as well.

<?php

$currentTime = microtime(true);


// Write some code which consume your CPU time
//...
// Find time difference in milliseconds

$timediff= round(microtime(true) - $currentTime,3)*1000;
echo "<h4>in ". $timediff. " Milli seconds </h4><br>";

?>