hi everyone hope you are all well...
i am login with userid and password and i want to display there username after login from my oracle database how?

Dani AI

Generated

As says, fetch the username (or display name) as part of the login query and save it in the session. Below is a concise, practical pattern using PHP's oci8 extension that shows the full flow: query by userid, verify the password in PHP, store a display name in the session, then output it safely.

<?php
session_start();

$userid = trim($_POST['userid'] ?? '');
$password = $_POST['password'] ?? '';

if ($userid === '' || $password === '') exit('Missing credentials');

/* connect - put credentials/DSN in config, not inline */
$conn = oci_connect('app_user','app_pass','dbhost.example.com/XEPDB1');
if (!$conn) { error_log(oci_error()['message']); exit('DB error'); }

$sql = 'SELECT display_name, password_hash FROM users WHERE userid = :uid';
$stmt = oci_parse($conn, $sql);
oci_bind_by_name($stmt, ':uid', $userid);
oci_execute($stmt);
$row = oci_fetch_assoc($stmt); /* column keys are UPPERCASE: DISPLAY_NAME, PASSWORD_HASH */

if ($row && isset($row['PASSWORD_HASH']) && password_verify($password, $row['PASSWORD_HASH'])) {
    session_regenerate_id(true);
    $_SESSION['userid'] = $userid;
    $_SESSION['display_name'] = $row['DISPLAY_NAME'];
    echo 'Welcome, ' . htmlspecialchars($_SESSION['display_name'], ENT_QUOTES, 'UTF-8');
} else {
    exit('Invalid login');
}

On other pages, call session_start() and echo htmlspecialchars($_SESSION['display_name'], ENT_QUOTES, 'UTF-8').

Troubleshooting & cautions: as suggested, show your code if stuck. Common issues: forgetting session_start(), Oracle returning column names in uppercase, not using bind variables (SQL injection risk), and mixing different password-hashing schemes. For production, store and verify secure hashes (use PHP's password_hash() / password_verify()), regenerate session IDs on login, set secure/httponly cookies, and avoid echoing raw DB errors to users.

Recommended Answers

All 3 Replies

Simply include the username is the result from the login query against the database. Then store it in session, or whatever persistance option is available to you. Then you have it available to use whenever you need.

sir please show also code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.