+ 1
what are the best ways to show different navbar based on if the user logged or not?
Hello 😊 I want to know what are the best ways to show different navbar based on if the user logged or not? like one way is to make two navbar in the html file and use css to make one display block and the other display none and switch between them using js. or another way is to use php "if statement"... What other ways there are ? and I know there is a lot of ways but what the easest way, also clean code. Thank you all :).
13 Antworten
+ 2
$myusername = mysqli_real_escape_string($db,$_POST['username']);
$mypassword = mysqli_real_escape_string($db,$_POST['password']);
$sql = "SELECT id FROM admin WHERE username = '$myusername' and passcode = '$mypassword'"; $result = mysqli_query($db,$sql); $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = $row['active'];
$count = mysqli_num_rows($result);
if($count == 1) {
session_register("myusername"); $_SESSION['login_user'] = $myusername;
echo "<div id =' login navbar'></div>";
}else {
die(" Error 504");
}
//HOPE IT HELPS
+ 3
Abbeymaniak Paul
Nope
But I advise you validate your form both client-side(js) and backend(php).
+ 2
if(mail($to, $subject, $message, $headers)){
echo "<script>alert("Sent Successfully");</script>";
header("Location: index.php");
} else {
/* Instead of using a function you can use die to handle errors */
die("Error");
}
#Abbeymaniak Paul
+ 1
If you use js, your server have to send more data (logged and not logged content) more js for handling they, client can "see" something of logged behaviours but all its a client work... Other side, your server have to "displatch" right page for your client then you get less data sendend and client have to do less work (but server a few much)... I would like second choice
+ 1
bros ishola please how can I get in touch with you? I'm a total novice and wanna get my website on d web.. please I need help
+ 1
thanks a lot bro, I have been expecting ur reply sir, I'm a strong follower. please do I have to deactivate any jquery handling form validation?
+ 1
God bless you for the reply bro, you be baba oooo, I dont mind learning from you sir
#ishola Obafemi
0
Thank you KrOW and Ishola Obafemi
I'm Front-End dev. and I'm just starting so my knowledge not that good but not bad also. I know that JS is not the best way and that's why I'm asking. I want to Know what ways there are. anyway thank you both you was very helpful 😊.
0
Abbeymaniak Paul what do you need ? mabey I can help you 😊
0
still on my contact form, how can I redirect after form submission to the index.php with an alert message of sent successfully! although I'm not using a phpmailer
0
this is the part I'm having issues:
if(mail($to, $subject, $message, $headers)){
header("Location: index.php");
} else {
function died ($error){
echo $error; }
0
the email do get sent and redirected to index.php but I wan. a message indication message sent
0
OK boss I'll work on that and get back to you, thanks a lot omo iyami
#ishola Obafemi