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 4077132
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:30:44+00:00 2026-05-20T17:30:44+00:00

I have gotten a snippet of code to bring back the username and password

  • 0

I have gotten a snippet of code to bring back the username and password and see if they match. i now want to set a session varaible to the ‘points’ value i have in the table which is in the same row as the username and pass.. what could be done?

    <?php $username="asdin";
$password="1sdA2";
$database="a75sdting";
$pword = $_REQUEST['pword'];
$uname = $_REQUEST['uname'];
mysql_connect('mysqsdst.com',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = mysql_query("SELECT * FROM `username` WHERE `password` = '$pword' AND `username` = '$uname'");
$exsists = 0;

        WHILE($rows = mysql_fetch_array($query)){
         $exsists = 1;
         break;
         }
            if ($exsists){
            $_SESSION['usern']=$uname;
            $_SESSION['logged']=1;

            header('Location: http://wwsdipts/logged2.php');


                    }



mysql_close();

 ?>

i want to set $_SESSION[‘points’] = $row[points] i guess… but i dont think that is correct

  • 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-20T17:30:44+00:00Added an answer on May 20, 2026 at 5:30 pm
    <?php
    
    // start session (required on every page that uses sessions
    session_start();
    
    // db auth
    $username="asdin";
    $password="1sdA2";
    $database="a75sdting";
    
    // user auth
    $pword = $_POST['pword']; // should use either $_POST or $_GET, NOT $_REQUEST
    $uname = $_POST['uname']; // should use either $_POST or $_GET, NOT $_REQUEST
    
    // open db connection
    $conn = mysql_connect('mysqsdst.com',$username,$password);
    @mysql_select_db($database,$conn) or die( "Unable to select database");
    
    // check user
    $query = mysql_query("SELECT * FROM `username` WHERE `password` = '$pword' AND `username` = '$uname'");
    
    if(mysql_num_rows($query)){
        // user exists
        $row = mysql_fetch_assoc($query);
        $_SESSION['usern']=$uname;
        $_SESSION['logged']=1;
        header('Location: http://wwsdipts/logged2.php');
    }else{
        header('Location: http://wwsdipts/login.php'); // take them back to login page if incorrect details
    }
    
    // close db connection
    mysql_close($conn);
    
    ?>
    

    I’ve tidied up your code a bit, please take a look at the notes. It is also worth nothing the following:

    1. You should be using some sort of protection against SQL injections, such as mysql_real_escape_string($_POST['uname']) – the same for password
    2. You need session_start() on all pages that use session variables
    3. You shouldn’t use $_REQUEST, use either $_POST or $_GET (read about it)
    4. Do you actually have a table named username? You should read up a bit about DB design, a better name/use for this table would be users as the table will be holding users (a combination of unique ID, username & password.
    5. I don’t know what you mean about points, but to access any column name in the “username” table, use $row['column-name'] after it is set ($row = mysql_fetch_assoc($query);)
    6. If you intend on using PHP a lot in the future, you should look up PDO, it’s a great class for handling SQL.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So have gotten to record in my F# journey and at first they seem
I have gotten round to implementing the ADD A,r set of opcodes on my
I have gotten this semi autogenerated code, but I am uncertain where the Post
Have gotten the foundation in place, but now, finding myself wanting to play around
I have gotten my config to work correctly now, there was a mismatch between
I have gotten reports from some people that they cannot log into my app
I have gotten the following errors using ruby 1.9.2-p320 with Heroku's Taps-using 'db' commands
I have gotten myself into a catch 22 and cannot seem to find my
I have gotten a great deal of help from KandadaBoggu on my last question
I seem to have gotten confused as to what the css clear keyword means.

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.