I want to display the login page before submitting the comment. When the user is not logged in and when he clicks on submit button it has to redirect to login page.. when the user is logged in the comment has to be posted. Here is the code.. Before user can comment if he is not logged in he has to redirect to login.php page.
<form action="" method="post">
<div class="row">
<div class="col-md-12">
<input type="hidden" class="form-control" id="email" placeholder="Name" name="name" value="<?php echo $_SESSION['name']; ?>" required>
</div>
<div class="col-md-12">
<textarea class="form-control" id="mes" name="mes" cols="30" rows="10" placeholder="Message"></textarea>
</div>
<div class="col-md-12 text-center">
<input type="submit" name="post" value="Post" class="texty" class="btn newspaper-btn mt-30 w-100" style="border:1px solid black;">
</div>
</div>
</form>
2
Answers
You can use the $_SESSION,
check the following on your comment button
You can try like this.