Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6876517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:29:13+00:00 2026-05-27T04:29:13+00:00

I have a buyer form, called Buyer.php: <form method=post action=check_buyer.php id=LoggingInBuyer> <div style=width:265px;margin:0; padding:0;

  • 0

I have a buyer form, called “Buyer.php”:

<form method="post" action="check_buyer.php" id="LoggingInBuyer">
    <div style="width:265px;margin:0; padding:0; float:left;">
    <label>Username:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span><a href="#">Forgot Username?</span></a></label> <br />
    <input id="UserReg" style="width:250px;" type="text" name="userName" tabindex="1" class="required" /></div>
    <div style="width:265px;margin:0; padding:0; float:right;">
    <label>Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span><a href="#">Forgot Password?</span></a></label> <br />
    <input id="UserReg" style="width:250px;" type="password"  name="userPass" tabindex="2" class="required" /></div>
    <div class="clearB"> </div>
    <input type="submit" style="width:100px; margin:10px 200px;" id="UserRegSubmit" name="submit" value="Login" tabindex="3" />
</form>

A file called check_buyer.php (in the same dir):

<?php
session_start(); #recall session from index.php where user logged include()

function isLoggedIn()
{
    if(isset($_SESSION['valid']) && $_SESSION['valid'])
        header( 'Location: buyer/' ); # return true if sessions are made and login creds are valid
    echo "Invalid Username and/or Password";  
    return false;
}

require_once('../inc/db/dbc.php');

$connect = mysql_connect($h, $u, $p) or die ("Can't Connect to Database.");
mysql_select_db($db);

$LoginUserName = $_POST['userName'];
$LoginPassword = mysql_real_escape_string($_POST['userPass']);
//connect to the database here
$LoginUserName = mysql_real_escape_string($LoginUserName);
$query = "SELECT uID, uUPass, dynamSalt, uUserType FROM User WHERE uUName = '$LoginUserName';";

function validateUser($ifUserExists['uID'], $ifUserExists['uUserType']) {
    $_SESSION['valid'] = 1;
    $_SESSION['uID'] = $uID;
    $_SESSION['uUserType'] = $uUserType; // 1 for buyer - 2 for merchant
}

$result = mysql_query($query);
if(mysql_num_rows($result) < 1) //no such USER exists
{
    echo "Invalid Username and/or Password";
}
$ifUserExists = mysql_fetch_array($result, MYSQL_ASSOC);

$dynamSalt = $ifUserExists['dynamSalt'];  #get value of dynamSalt in query above
$SaltyPass = hash('sha512',$dynamSalt.$LoginPassword); #recreate originally created dynamic, unique pass

if($SaltyPass != $ifUserExists['uUPass']) # incorrect PASS
{
    echo "Invalid Username and/or Password";
}else {
    validateUser();
}
// If User *has not* logged in yet, keep on /login
if(!isLoggedIn())
{
    header('Location: index.php');
    die();
}
?>

// This is now throwing error of: Parse error: syntax error, unexpected ‘[‘, expecting ‘)’ in on line 23 which is function validateUser($ifUserExists['uID'], $ifUserExists['uUserType']) {

and the file “index.php” in the buyer/ directory:

<?php
session_start();
if($_SESSION['uUserType']!=1)
{ 
    die("You may not view this page. Access denied.");
}

function isLoggedIn()
{
    return (isset($_SESSION['valid']) && $_SESSION['valid']);
}

//if the user has not logged in
if(!isLoggedIn())
{
    header('Location: index.php');
    die();
}
?>

<?php 
    if($_SESSION['valid'] == 1){
        #echo "<a href='../logout.php'>Logout</a>";
        require_once('buyer_profile.php');
    }else{
        echo "<a href='../index.php'>Login</a>";
    }
?>

The point of this is that when a username and password is entered, the user is logged in and directed to /buyer/index.php, to the buyer portion of that website. It seems everytime I login with the dummy credentials I made to test, it just blurts out : You may not view this page. Access denied. But, then if I go back by pressing back arrow in browser it has me logged in and showing a link to logout.

I did some trouble shooting:
1) Shown here, to test my sql query is fine and indeed it is. https://i.stack.imgur.com/n2b5z.png

2)Tried choing out echo 'the userid: ' . $userid; before it whines about You may not view.. and it doesn’t print anything.

How do I go about getting this userID? I double checked the field names in the database and all is fine..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:29:14+00:00Added an answer on May 27, 2026 at 4:29 am

    From a quick check, it looks like you’re setting $_SESSION['uUserType'] = $userType in validateUser(), but don’t seem to be passing in $userType itself to that function. So $_SESSION['uUserType'] won’t be 1, but $_SESSION['valid'] will be, because you’re setting it to that in validateUser().

    I suspect you should be passing valid data in to validateUser in order to set it into the session.

    e.g.

    validateUser($ifUserExists['uID'], $ifUserExists['uUserType']);
    
    function validateUser($uID, $uUserType) {
        $_SESSION['valid'] = 1;
        $_SESSION['uID'] = $uID;
        $_SESSION['uUserType'] = $uUserType; // 1 for buyer - 2 for merchant
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have buy.php with a form where you enter items, quantity, shipping data, etc.
So lets I have a Transactions model. Transactions.rb has: belongs_to :buyer, :class_name => User
i have this code SELECT DISTINCT idx_campus_bookinfo,c.userid as Buyer,bookname,book_explain,writedate FROM campus_bookinfo cb LEFT JOIN
I have a simple login form. When I click Login, the a4j:commandButton works well
I have the following scenario in MVC2 /VS 2008: A user form with 2
This question is somehow similar to this one . I have a form in
Basically, I have two files, in two different directories: index.php (in /login/) and index.php(in
I have 2 pages for collecting payments for an online services business. 1st form
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.