Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Username Session Input?
11-12-2011, 01:47 AM #1
- Join Date
- Oct 2011
- Thanked 1 Time in 1 Post
Username Session Input?
Alright so the title may be a bit misleading but im working on a social network and i have it at the point where users can Register, log-in, Update Status's, and upload pictures.
My question is with the upload part of the social network. I have my upload.php that uses connect.php to connect to the database, then after uploading there is a view.php to view the image. My Login files and Upload files were coded separately and now im implementing them together.
At the top of upload.php i have:
$username = $_SESSION['username'];
If i didn't do a good job at explaining or you need more explaining let me know.
Thanks Much, -Anthony
$error = "Unable to connect.";
$connect = mysql_connect("localhost","root","") or die ($error);
mysql_select_db("phplogin") or die ($error);
$username = $_POST['username'];
$password = $_POST['password'];
$connect = mysql_connect("localhost","root","") or die("Couldn't connect!");
mysql_select_db("phplogin") or die ("Couldn't find db");
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
while ($row = mysql_fetch_assoc($query))
$dbusername = $row['username'];
$dbpassword = $row['password'];
// check to see if they match
echo "You're in! <a href='member.php'>Click</a> here to continue to the site.";
echo "Incorrect password!";
die("That user doesn't exist!");
die("Please enter a username and passord");
Last edited by skill3d; 11-12-2011 at 01:49 AM.
11-12-2011, 09:25 AM #2
- Join Date
- Jan 2011
- Thanked 660 Times in 659 Posts
You set $_SESSION['username']; in your login script. You can place that anywhere you want it with php by placing this where the name should be:
<?php echo $_SESSION['username']; ?>
But you should do some work on your login script.