The below is only an example.
You have to check whether the user is logged in using php, and save it in a cookie and then make the calculation using jQuery.
Do not use id
to check if the user is logged in, because it is not secured. If the user inspects, and removes the id, he will be able to write in the box without logging in.
To redirect the user, instead of using alert
, use window.location.href=""
$(function() {
$("#isNotLogged").click(function() {
$("#isNotLogged").blur();
alert('Please login');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea id="isLogged" placeholder="Textarea for Logged in"></textarea>
<br />
<textarea id="isNotLogged" placeholder="Textarea for Not Logged in"></textarea>
solved How can I turn a