Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to know how to display time since a user has submitted the form on my website. So for example when the user submits the form I was to display
"Thank-you for your submission. You have been logged in for 0 seconds" depending upon the time that has elapsed." Can I use the time() function but am not sure to process it.
When the user login store the time in a session variable like this:
$_SESSION['usertime'] = time();
Then when the user submits the form you simply minus the current time from that session variable time.
echo "You have been logged in for "
. round(abs($_SESSION['usertime']- time()) / 60,2). " minute";
You can use time function like this.
<?php
$time=time();
echo($time . "<br>");
echo(date("Y-m-d",$time));
?>
echo date("Y-m-d H:i:s");//current date
echo date("H:i:s");//current time
you can search in net before ask:D
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am working on a e-commerce website. I want a help regarding displaying login & logout but when a user is logged in, user should only get logout option & when logged out user should get login option.
Please help me regarding this concept.
you can create SESSION variable (with email or any unique attribute) and set it when user LogsIn.
eg: session_start();
$_SESSION['email'] = useremail;
and check in every page if session varible is set or not.
session_start();
if(!isset($_SESSION)){
//then show login button
}
else{
//show logout button
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a log in in page where by when I i log in it takes me to my homepage which has a <div class="alert alert-success> message.
I want this message to show for like 5 seconds then it fades out.
How do I do that??
Also when i refresh my page I don't want the message to show again unless i log out then log in again.
this is some of the code:
×
success! Login successfull!
This is supposed to show when i have successfully logged in.
You could use php to create set a session variable and then clear it after it's been displayed.
session_start();
$_SESSION['new_message'] = true;
if(isset($_SESSION['new_message']){
//your code to display the message
session_destroy;
}
To fade after 5 seconds use jquery
$('#div').delay(5000).fadeOut(400)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to get my country's current date. Currently my project is getting the user's date.
Here are my questions:
how to get my country's current date?
If I'm running my php site in my localhost (wampp), will I still get my country's current date? (I have an internet connection by the way).
PHP fetches time info from the server (your local system in this case). Then, with date_default_timezone_set() you can set any time zone you need.
Please, try this simple code and see what happens:
America/Montreal:<br>
<?php
date_default_timezone_set("America/Montreal");
echo date("Y/m/d H:i:s", time());
?>
<br>
Asia/Aden: <br>
<?php
date_default_timezone_set("Asia/Aden");
echo date("Y/m/d H:i:s", time());
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a form which user submits and I get the current time and date in the database and facebook ID of the user as well, As per rule the user can fill the form only once in a week, so if he fills the form on Tuesday, he is not eligible to fill the form unless the week is complete, (Only eligible to complete the form again on next Monday)
I am trying to find some php function for weeks but couldn't get so, Anyone can help me what can be done for this logic?
I have date/time in the db for me.
First, you are basically looking for
$date = "2014-10-13";
$week=date("W", strtotime($date));
or even use it this way
$date = "2014-10-13";
$date = new DateTime($date);
$week = $date->format("W");
( http://php.net/manual/en/function.date.php )
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
<?php
$id=721914338;
setcookie("id",$id,time()+1200,'/');
?>
This is just a example so I can ask my question . My question is this that I am capturing id from facebook , google or twitter . I am inserting into the database but the problem is this that when i store it in the cookie and use this cookie in the next page or any other page . By using the sql query whether the user has this id or not which is stored in cookie . As a developer , any user has knowledge about INSPECT ELEMENT , he or she can read my id so how to protect from hacking ? please can anyone help me ?
I don't want to store it in session, I want to store it in cookie only . Is there any to encrypt the id and in every page decrypt it use it . Is there any when the user refreshes the page , the timer will start again
You can store this id into session variable. Every time a user is login into site you fetch its id from data base and store into session variable in php. Using session you can get the value in any page.