Dear all,
Below here I show you a redirected page from a login.php where shows the results os the login session.
This page will be once again redirected to an edit_user.php page.
The question is how do I retrieve this loggedin user_id from the database.
I have already tried GET_uid and many other forms of request without success.
I would be GREATFUL if any one could help me by that ! THANKS A LOT! -
if (isset($_SESSION['first_name']) && ($_SESSION['last_name' ]) && ($_SESSION['email']) && ($_SESSION['user_id']) && ($_SESSION['registration_date']) ) {
-
?><td><?php
-
echo "<br /><br /><fieldset><p>Welcome, {$_SESSION['first_name']} {$_SESSION['last_name']}!</p>
-
<p>E-mail address: {$_SESSION['email']}</p>
-
<p>Registration date: {$_SESSION['registration_date']}</p>
-
<p>Your ad...(s)</p>
-
<p>User_id: {$_SESSION['user_id']}</p>";
-
echo "</fieldset >";
-
-
}
-
-
if (isset($_GET['uid'])) {
-
$uid = (int) $_GET['uid'];
-
if ($uid > 0) {
-
$query = "SELECT user_id AS $uid FROM users WHERE user_id = $_SESSION[user_id]" ;
-
$result = @mysql_query ($query);
-
-
echo '<table>
-
<tr>
-
<td align="left"><a href="edit_user.php?view= ' . $SESSION['user_id'] . '">Edit</a></td>
-
<td align="left"><a href="delete_user.php?view= ' . $SESSION['user_id'] . '">Delete</a></td>
-
</tr>
-
'
-
; '</table>' ;
-
-
}
-
mysql_close();
-
}
-
THANK YOU VERY MUCH ! Naira
7 2251 Atli 5,058
Expert 4TB
Hey.
Is the session variable not working?
The "$SESSION['user_id']" element that is used several time in that code, I mean.
Try to echo ur select statement,check if the sql is ok ....
Most probably da problem is somewhere on the sql mostly in line 15..
What does it give u?
@Atli
Hi Atli,
The $_SESSION is working to loggin the user e show the user his name, email, etc, but not to identify him as a retrieved user_id on the page. Nothing else shows up besides the profile of the user.
Many thanks.
Naira
@phpuser123
hi phpuser123,
Thanks for your help.
The sql is running without problems. I have other exercices and everything is doing properly.
I will try yr hint. Meanwhile I found an strong example online from an anonymous and I will try that too tomorrow.
Many thanks
Naira
The problem is the AS statment in the sql query.
AS is used to create an alias of a table name or column name. Say you had a table called very_extremly_long_col_name it is much more convenient to reference this as velt
so you would write -
SELECT very_extremly_long_col_name AS c1 FROM some_table WHERE c1=3
-
-
// Then the result would be delivered like this in your php code
-
$result['c1'];
-
-
-
// instead of if not using AS
-
SELECT very_extremly_long_col_name FROM some_table WHERE very_extremly_long_col_name=3
-
-
// imagine getting data from several long named tbls and column and you'll see its a beneficial feature
-
-
So what you need to do is get rid of the AS statement in the sql.
@Naira
Also if you didn't notice or if it is a simple typo you have used $SESSION in your delete and edit links instead of $_SESSION which you had correctly used in your sql statement.
@rythmic
Hello Rythmic,
Sorry for the delay, I was on vacation.
Thank you very much for your suggestion, but the solution was simply this one below: -
-
if (isset($_SESSION['user_id']) AND
-
(substr($_SERVER['PHP_SELF'], -10)
-
!= 'logout.php')) {
-
-
echo '<br /><table>
-
<tr>
-
<td align="left"><a href="edit_user.php">Edit</a></td>
-
<td align="left"><a href="delete_user.php">Delete</a></td>
-
</tr>
-
';
-
echo "</table>";
-
-
} ]
Nothing more than that.
Thanks any way!
Have a nice weekend.
Naira
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bob Kaku |
last post by:
I'm trying to retrieve a text value from a MySQL database, put it into
an updateable form, allow edits, and send back the edited text back
into the MySQL database. I've been able to successfully...
|
by: theonlydrayk |
last post by:
the script that show image is :
<?php
include('dbinfo.inc.php');
mysql_connect($localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query =...
|
by: Robert Kattke |
last post by:
Subject: Can you retrieve/restore a MySQL user Password ?
I'm working on my own, local WXP, MySQL, version: 3.23.38-nt
and I have the "root" password, and normally use the root account.
I have...
|
by: Daniel Tonks |
last post by:
First, please excuse the fact that I'm a complete MySQL newbie.
My site used forum software that I wrote myself (in Perl) which, up until
now, has used flat files. This worked fine, however...
|
by: Shimon Sim |
last post by:
I am working with LogIn control and need to set some property for profile
after user is authenticated. I thought that LoggedIn event is the right
place but system tells me that the property can't...
|
by: Jav |
last post by:
I need to get at the ProviderUserKey of the logged in user. I would have
thought that I could do something like:
Dim u As MembershipUser = Membership.GetUser
Dim ProvKey as Guid =...
|
by: Daz |
last post by:
Hi everyone.
Firstly, I apologise if this i not what you would call a PHP problem. I
get quite confused as to what lives in which realm, so if this
shouldn't be posted here, please suggest where...
|
by: damezumari |
last post by:
When a user logs in to my site http://iwantyourquestion.com I set
$_SESSION to true if his username and password are OK.
When he calls a page I check if $_SESSION is true. If it
not I ask him to...
|
by: Vio |
last post by:
Hello everyone,
i currently a beginner in php.
I want to ask about Win2003 Active Directory users. Is it possible to
retrieve Win2003 AD (just username & password) with php.
I'm currenty...
|
by: santhanalakshmi |
last post by:
Hi,
Please help me out.....
I have created an user in the Mysql database with the password.
user : san
password : san
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |