Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
php want show error inpu1 > input2
05-20-2014, 07:32 AM
Post: #1
php want show error inpu1 > input2
I designed a php page if current time is greater than end time it show as closed else it show data entry form.
In that form I have several input boxes some get value from database.remain input boxes accept value less than their pair input box.else it show error and focus user to change that field how ... I tried with following code but cannot get expected result... Any solution...



<?php
include("head.php");

?>
<?php
$end = ('04:15:00 PM');
$now=date('H:iconfused A');?>

<?php
$newdateformat = date("d_m_y");
$ttaerr="";
mysql_select_db($mysql_database,$bd);
$se_sql=mysql_query("select * from $newdateformat where S_No='$login_sess' ");

$row=mysql_fetch_array($se_sql);
$name=$row['S_Name'];
$address=$row['Address'];
$tamil= $row['Tamil1'];
$english=$row['English1'];
$maths= $row['Maths1']; ?>

<label> Your Name : <?php echo $login_sess;?> - <?php echo $name;?> - <?php echo $address;?> </label><br />
<?php


if($end > $now){
echo "Entry 1 Closed :";

}

else
{
?>




<form id='form1' name='form1' method='post' action='<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>'>'

<p>
<label for='tamil1'>Tamil 1 : </label>
<input name='tamil1' type='text' id='tamil1' value='<?php echo $tamil;?>' readonly="readonly" disabled="disabled"/>
</p>
<p>
<label for='tamil2'>Tamil 2 : </label>
<input name='tamil2' type='text' id='tamil2' maxlength="3" required='required' /> <?php echo $ttaerr;?>
</p>
<p>
<label for='tamil1'>English 1 : </label>
<input type='text' name='english1' id='english1' value='<?php echo $english;?>' readonly="readonly" disabled="disabled"/>
</p>
<p>
<label for='tamil2'>English 2 : </label>
<input type='text' name='english2' id='english2' required='required' maxlength="3" />
</p>
<p>
<label for='tamil1'>Maths 1 : </label>
<input type='text' name='maths1' id='maths1' value='<?php echo $maths;?>' readonly="readonly" disabled="disabled" />
</p>
<p>
<label for='tamil2'>Maths 2 : </label>
<input type='text' name='maths2' id='maths2' required='required' maxlength="3" />
</p>
<p>&nbsp;</p>
<p>
<input type='submit' name='submit' id='submit' value='Submit' />
</p>

</form>
<?php

if($_SERVER['REQUEST_METHOD']=="POST")
{ if(isset($_POST['tamil1'])&&isset($_POST['tamil2'])&&isset($_POST['english1'])&&isset($_POST['english2'])&&isset($_POST['maths1'])&&($_POST['maths2']))
{
$newta1=$_POST['tamil1'];
$newta2=$_POST['tamil2'];
$newen1=$_POST['english1'];
$newen2=$_POST['english2'];
$newma1=$_POST['maths1'];
$newma2=$_POST['maths2'];

if(($newta1 > $newta2)&&($newen1 > $newen2)&&($newma1 > $newma2))
{
$sql="UPDATE $newdateformat SET Time='$now',Tamil2='newta2',English2='$newen2',Maths2='$newma2' WHERE S_NO='$login_sess' and S_Name='$name'";

$result=mysql_query($sql);

if(!$result)
{
die ('Error:'.mysql_error().'<br> <a href=""> Back</a>');
}
echo 'Your Record added on :'.$now.'<br> <a href=""> Back</a>';
mysql_close($con);
}
else {
echo("Try Eng...");

}}
}

}

?>
</body>
</html>
Find all posts by this user
Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)