loveme Posted May 20, 2014 Share Posted May 20, 2014 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:i:s 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> </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> Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 20, 2014 Share Posted May 20, 2014 (edited) 1 - use the code tags as described in the forum's rules. They are the little <> icon in the editor menu or simply code and /code wrapped in brackets. 2 - you can't compare a string (which $end is) to a date value (which $now is). Try: $end = strtotime('04:15:00 PM'); 3 - your table names are dates? Really? There may be more but those two things are a start Edited May 20, 2014 by ginerjm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.