0 Users appreciate this thread.
angelrulez7 (2014-01-07 03:39:57)I've never really found a problem with using the code. ^
EDIT: I see where you're going, but all processes are stored in one file with me.
2014-01-07 04:02:10
a
(Capt.)Orb (2014-01-07 23:27:40)You need to expand the variable to actually get the value of $username...
To show you, this is one way of doing it..
Also, you forgot a = on the input bar.
Source Code
<?php session_start(); //Can be changed if you do not use sessions $username = $_SESSION['username']; //Make it easier, can be changed to your display code if($username){ echo "Welcome, $username!" . '<br>Durhur stuff here'; }else{ echo 'Welcome, Guest!' . '<br> <form action stuff and stuff> Username:<br><input username><br> <input pass><br><tickbox and whatnot> Remember me?<br><input type=submit> </form><br><new account link>'; //Be sure to edit this correctly! } ?>
<?php session_start(); //Can be changed if you do not use sessions $username = $_SESSION['username']; //Make it easier, can be changed to your display code if($username){ echo "Welcome, $username!" . '<br>Durhur stuff here'; }else{ echo 'Welcome, Guest!' . '<br> <form action stuff and stuff> Username:<br><input username><br> <input pass><br><tickbox and whatnot> Remember me?<br><input type=submit> </form><br><new account link>'; //Be sure to edit this correctly! } ?>
2014-01-07 23:31:01
Aviation fact: The a380 is the largest commerical aircraft in service!
Go to Splashiverse! Splashiverse
Go to Splashiverse! Splashiverse
angelrulez7 (2014-01-08 01:51:00)[code=*php]
<?php
//I made a workaround for my login. I also fixed a few mistakes and disabled the Guest feature
include('include/session.php'
$username = $session->username; //Make it easier, can be changed to your display code
if($_GET['log']){
$username = 'FakeUser';
}else
if($username == "Guest"
$username = '';
}
if($username){
echo 'Welcome, ' . $username . '!<br>Durhur stuff here';
}else{
echo 'Welcome, Guest!' . '<br>
No login here because it was not real html'; //Be sure to edit this correctly!
}
?>[/code]
Try http://social-ring.tk/proof.php (While not logged in to SocialRing, make sure of that) and then click the link there. There is no problem at all.
2014-01-08 01:52:15
a
PLMasterSSB (2014-01-08 05:48:51)yes, its easier that way. but in some cases, redirects may be needed.
^ Click
(This Image was created from cooltext.com)
(Capt.)Orb (2014-01-08 17:36:04)Ah, I saw you edited your first post to .$username.
2014-07-09 05:23:27
Aviation fact: The a380 is the largest commerical aircraft in service!
Go to Splashiverse! Splashiverse
Go to Splashiverse! Splashiverse
(Capt.)Orb (2014-01-09 20:45:17)^ Very well, I don't really care. Just being kind by reporting errors.
Aviation fact: The a380 is the largest commerical aircraft in service!
Go to Splashiverse! Splashiverse
Go to Splashiverse! Splashiverse
(Capt.)Orb (2014-01-11 00:21:29)Never mind..
Aviation fact: The a380 is the largest commerical aircraft in service!
Go to Splashiverse! Splashiverse
Go to Splashiverse! Splashiverse
joemckellar20 (2014-05-07 04:17:10)it's not working
[REMOVE REQEST]
2014-05-07 11:18:27
Log in to submit a comment
Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)
New registered users today: 7
Newest registered user: ElegantVulpes
The title is not very specific, but I shall explain here.
So, basically, I have recently seen sites that have a homepage that if $_SESSION['username'] has no variable, it redirects you to "login.php" to login. I find it inconvinient because you need to keep being redirected. As well as Android's default browser (DO NOT USE) disliking multiple server redirects.
Here is a basic code (that probably anyone can guess but doesn't think to do) that can resolve this problem.
[code=*php]
<?php
session_start(); //Can be changed if you do not use sessions
$username = $_SESSION['username']; //Make it easier, can be changed to your display code
if($username){
echo 'Welcome, ' . $username . '!<br>Durhur stuff here';
}else{
echo 'Welcome, Guest!' . '<br>
<form action stuff and stuff>
Username:<br><input username><br>
<input pass><br><tickbox and whatnot>
Remember me?<br><input type submit stuff>
</form><br><new account link>'; //Be sure to edit this correctly!
}
?>[/code]
I've just made a basic homepage (very lazily and with no real html on the login form) with 2 versions. One part (if $username is active) for the main homepage, and one part ($username is not active) for the login form.
If I messed up on the code, please tell me. It's 2:35 AM and I needed something to do.
Good luck on your coding ventures!
2014-01-08 01:53:19