Jump to content

bal bal

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Posts posted by bal bal

  1. Hi there, I have a login table which shows the login details, the login & logout time. but it does not show my pc time. it shows the time which is 1 hour ahead of my laptop. can anyone plz tell me how can I solve the problem?

    here is the all code.

    <?php 
    session_start(); 
    require_once("config.php");
    if(!$_SESSION['username'])
    {
    header("Location: loginpage.php");
    }
    ?>
    
    
    <?php
      $query="select f_name from student_details where username='".$_SESSION['username']."'";
      $res=mysql_query($query);
      $data=mysql_fetch_object($res);
      
    
      
      ?>
    
    <?php
    		  function get_time_difference( $start, $end )
    {
        $uts['start']      =    strtotime( $start );
        $uts['end']        =    strtotime( $end );
        if( $uts['start']!==-1 && $uts['end']!==-1 )
        {
            if( $uts['end'] >= $uts['start'] )
            {
                $diff    =    $uts['end'] - $uts['start'];
                if( $days=intval((floor($diff/86400))) )
                    $diff = $diff % 86400;
                if( $hours=intval((floor($diff/3600))) )
                    $diff = $diff % 3600;
                if( $minutes=intval((floor($diff/60))) )
                    $diff = $diff % 60;
                $diff    =    intval( $diff );            
                return( array('days'=>$days, 'hours'=>$hours, 'minutes'=>$minutes, 'seconds'=>$diff) );
            }
            else
            {
                trigger_error( "Ending date/time is earlier than the start date/time", E_USER_WARNING );
            }
        }
        else
        {
            trigger_error( "Invalid date/time data detected", E_USER_WARNING );
        }
        return( false );
    }
    
    		  /*$query="select * from student_details where username='".$_SESSION['username']."'";
    		  $result=mysql_query($query);
    		  $fetch=mysql_fetch_object($result);*/
    		  
    		$qry="select * from userlogin_info where user_id ='".$_SESSION['username']."'";
    		  $res=mysql_query($qry);
    		  
    		  	$i=0;	  
    		while($usrObj = mysql_fetch_object($res))
    			{
    			if($i%2!=0)
    			{
    			$trcolor = "#666666";
    			}
    			else
    			{
    			$trcolor = "#333333";
    			}
    			$login_time="";
    			$logout_time="";
    			$login_time=$usrObj->login_time;
    			$logout_time=$usrObj->logout_time;
    
    			$ex_login_time="";
    			$ex_logout_time="";
    			$ex_login_time=substr("$login_time",-8,;
    			$ex_logout_time=substr("$logout_time",-8,;
    
    
    
    
    ?>
    
    
    <?php if( $diff=@get_time_difference($ex_login_time, $ex_logout_time) )
    {
      
          echo  sprintf( '%02d:%02d:%02d', $diff['hours'], $diff['minutes'],$diff['seconds'] );
    }
    else
    {
    
    }
    ?>
    
    
    <?php
    		  $i++;
    }
    ?>
    
    

    these all codes are in the same file.

     

    thanks

     

  2. hi

    i've got a login script from the net. its working perfectly. but i can't understand "i=f" after the php file name. here it is...

    <form action="actions/login.php?i=f" method="post">

    can anyone please help me?

    thanks

  3. Here you go

     

     print("Please enter a valid forename<br>");
     print ("</body></html>");

     

    or

     echo "Please enter a valid forename<br>";
     echo "</body></html>";

     

    thanks a lot Mchl

  4. Hi

    this is how it print in the in the perl, can anyone please tell me how to print them in the PHP.

     

    	 print "Please enter a valid forename<br>";
     print "</body></html>";

     

    thanks in advance

  5. Why do you have an empty option in your select field?

     

    if I don't put an empty option, & the user don't change it, that means the user choose the wrong option.

    thats why I want to make sure the user choose the right one and if it is blank, it should says "you have to choose one option from the list"

  6. if you don't select any thing from the list, why it is not showing any message, like "please choose one from the list"

     

    Maybe I'm confused but with a SELECT, the first option is automatically selected by default, so it's impossible for someone not to choose an option.  Am I missing something...?

     

    yes.....

    this is the code for select

    <select name="list">
    <option></option>
    <option value="car">car</option>
    <option value="bus">bus</option>
    <option value="motorbike">motorbike</option>
    </select>

     

    so 1st option is not selected.

    its still not working >:( >:(>:(

     

    when I tried with this code, it shows me "The page cannot be found" error >:(:(

  7. if you don't select any thing from the list, why it is not showing any message, like "please choose one from the list"

     

    Maybe I'm confused but with a SELECT, the first option is automatically selected by default, so it's impossible for someone not to choose an option.  Am I missing something...?

     

    yes.....

    this is the code for select

    <select name="list">
    <option></option>
    <option value="car">car</option>
    <option value="bus">bus</option>
    <option value="motorbike">motorbike</option>
    </select>

     

    so 1st option is not selected.

    its still not working >:( >:(>:(

  8. Yeah, you have a lot of syntactical errors, and since you don't have them turned on it just shows a blank page.

     

    If you put this code at the top of your page it will display the errors that you have:

     

    ini_set ("display_errors", "1");
    error_reporting(E_ALL);

     

    Like unska said, here is the solution, they HAVE TO choose an option from the drop down:

     

    <?php
       if(isset($_POST['submit'])) {
          echo $_POST['list'];
       }
    ?>
    
    <html>
    <head>
    </head>
    <body>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <select name="list">
    <option value="car">car</option>
    <option value="bus">bus</option>
    <option value="motorbike">motorbike</option>
    </select>
    <br>
    <input type="submit" name="submit" value="Submit!">
    </form>
    </body>
    </html>

     

    if you don't select any thing from the list, why it is not showing any message, like "please choose one from the list"

  9. It's actually quite basic PHP, here's the solution:

     

    <?php
    if ($_POST) {
    	echo $_POST['list'];
    }
    ?>
    
    <html>
    <head>
    </head>
    <body>
    <form action="thisfile.php" method="post">
    <select name="list">
    <option value="car">car</option>
    <option value="bus">bus</option>
    <option value="motorbike">motorbike</option>
    </select>
    <br>
    <input type="submit" name="submit" value="Submit!">
    </form>
    </body>
    </html>
    
    

     

    I tried with this code....

     

    <?php
    
    if (trim($_POST['list'])<="" { $error = "Please pick from the list";
    else    
    echo "You selected ". " " . $_POST['list'] . ".<br />";  
    //echo $_POST['list'];
       }
    ?>

     

    but it shows me nothing. did I make any mistake?

  10. What do you mean?  If you have 3 things in the list, only those 3 things are available to be selected...  Just make the first one selected by default.

    these are in menu bar, when I click on the menu, these 3options will come but I've to select only 1. so how can I validate it if I don't select any or if I select any one of them...

     

  11. How can I get the value from the select box, where the value is (car, bus, motorbike), should select anyone of them from the list. if not selected it should give an warning... "select the right vehical"

    please help me.....

     

    thanks

     

  12. hi

    here is my code for name field which is a text box. it is working if I put any digit or if the field is empty but when I put the symbols like '%$%^&*!' it still takes the value not showing any error.

     

    if ((is_numeric($name))||(empty($name)))
    
            {
    
            echo 'please enter your name<br>';
    
            return;
    
            }

     

    can anyone please help me...

     

    thanks

  13. hi

    I have got a form with name, email address and choose the pet from the list (cat or dog). How can I do the form validation with PHP, if anyone put the wrong name or invalid email address and don't choose anything from the pet list?

    please help me...

     

    thanks

     

     

  14. Depending on what type of inbox box you're using on your form (and what data it contains) depends really on how you validate the data - and how strict you want to be with it.

     

    For example, validating something like a name is easy - either it has content or it doesn't. This can be checked using empty()

    if (empty($name)) {echo 'We are empty!';}

     

    For dates you can very specific or relaxed. Does it matter what order the d/m/y are in or can they use whatever format they want?

     

    thanks for the reply.

    Just to make it a bit clear.

    I have got a textbox for name and another one for email address and a select button (value is cat, cow, dog) from where I will select one and validate the user name and email address.

    so the name field should not contain any digit and the email address should be a valid email address...

    thanks once again

     

  15. Hi I am new in PHP, I did this using perl but don't know how to do the form validation using PHP. here is the code for perl. can anyone please help me how can I do the form validation using PHP. I have got "text box" and "select" from the list in the PHP form.

    Thanks in advance.

     

    #!/usr/bin/perl - w
    
    use CGI ':standard';
    use CGI::Carp "fatalsToBrowser";
    use DBI;
    
    print header;
    
    $forename=param('txtfname');
    $surname=param('txtsurname');
    $day=param('lstday');
    $month=param('lstmonth');
    $year=param('lstyear');
    $passport=param('txtpassport');
    $gender=param('lstgender');
    $email=param('txtemailadd');
    $phone=param('txtphone');
    $galaxy=param('lstgalaxy');
    $flightdate=param('dptdate');
    $flightmonth=param('dptmonth');
    $flightyear=param('dptyear');
    
    print "<html> <body bgcolor=\"burlyWood\">";
    
    if ($forename !~/\A[A-Z][a-z]+\Z/i)     
    {
     print "Please enter a valid forename<br>";
     print "</body></html>";
    }
    else	{
    print "Forename: $forename <br>";
    } 
    
    if ($surname !~/\A[A-Z][a-z]+\Z/i)     
    {
     print "\n Please enter a valid Surname <br>";
     print "</body></html>";
    }
    else	{
    print "\n\nSurname: $surname <br>";
    
    } 
    
    if ($day !~m/\d/)
    {
     print "Please choose the valid date<br>";
     print "</body></html>";
    }
    else 	{
    print "Date of Birth "; 
    print "$day/"; 
    }
    
    if ($month !~m/\d/)
    {
     print "Please choose the valid month<br>";
     print "</body></html>";
    }
    else 	{
    print "$month/"; 
    }
    
    if ($year !~m/\d/)
    {
     print "Please choose the valid year<br>";
     print "</body></html>";
    }
    else 	{
    print "$year<br>"; 
    }
    
    if ($passport !~m/\d/)
    {
     print "Please enter 4 digits(0 to 9)";
     print "</body></html>";
    }
    else 	{
    print "Passport Number: $passport <br>"; 
    } 
    
    if ($gender !~/\A[A-Z][a-z]+\Z/i)
    {
     print "Please choose a gender<br>"
    }
    else
    {
    print"Gender: $gender<br>";
    }
    if ($email !~m/\A[A-Z][a-z]|d+\@\[A-Z][a-z]|d+\.\[A-Z][a-z]|d+\z/i)
    {
     print "Please enter a valid email address<br>";
    }
    else
    {
     print "Email: $email<br>";
    }
    if ($phone !~m/\A\d+\Z/)
    {
     print "Please enter a valid phone number<br>";
     print "</body></html>";
    }
    else 	{
    print "Phone Number: $phone <br>"; 
    } 
    
    if ($galaxy !~/\A[A-Z][a-z]+\Z/i)
    {
     print "Please choose one from the list<br>"
    }
    else
    {
    print"Galaxy: $galaxy<br>";
    }
    
    if ($flightdate !~m/\d/)
    {
     print "Please choose the valid date<br>";
     print "</body></html>";
    }
    else 	{
    print "Departure Date ";
    print "$flightdate/"; 
    }
    
    if ($flightmonth !~m/\d/)
    {
    
     print "Please choose the valid month<br>";
     print "</body></html>";
    }
    else 	{
    
     print "$flightmonth/"; 
    }
    
    if ($flightyear !~m/\d/)
    {
     print "Please choose the valid year<br>";
     print "</body></html>";
    }
    else 	{
    print "$flightyear<br>"; 
    }
    
    

  16. how have you stored these details? What is the login method you used? Is there a database involved, etc. etc.

    i've got a table called log_dtls where it stores the user name and password. what I want is, when I logged in, it should show the user name and the last login details, like when logged in before. it should like the bank account page, when you logged in your account, it shows your name and when you last logged in....

     

    thanks

  17. hi

    when I logged in, the details (user ID & last loggin in time) should show in each pages... can anyone please help me how can I do this?

    I have got login page with user name and password. when I logged in, it shows the details in the in each pages untill I logged out.

    can anyone please help to how can I do this?

     

    thanks

  18. Hi this is Sha. I don't know how to start. I am going to design a database where there will be two tables, one for log in details and another one will be for student marks. There should be a standard say 40 marks. If any student gets less than 40, and everytime when he/she log in to the system, it will show him/her a message say for example "do more practice" until he/she reach the standard.

    I have got no clue how to start. Can anyone please help me to how to start?

    I am sorry if I post this in the wrong forum.

    Thanks...

     

    Sha 

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.