Jump to content

$_GET Isn't Getting


Joseph Witchard

Recommended Posts

<?php

  $user_id = $_GET['user_id'];

  // start the session
  
  session_name('pickles');
  session_set_cookie_params(900);
  session_start();
  
  
  
  // verify session
  
  if (empty($_SESSION) || $_SESSION['news'] != true)
  {
  
    // redirect them
    
    header("Location: https://uhrebirth.com/staff/admin_login.php");
    
    exit;
    
  }
  
  // require the connection settings
  
  require_once("path_to_connection_settings);
  
  // connect to the database
  
  $conn = sdaAccess();
  
  
  
  // write the query
  
  $query = "SELECT user_id, username, pwd, user_email FROM users WHERE user_id = ? LIMIT 1";
  
  // prepare the statement
  
  if ($stmt = $conn->prepare($query))
  {
  
    // bind the parameters
    
    $stmt->bind_param('i', $user_id);
    
    // execute
    
    if ($stmt->execute())
    {
    
      $stmt->bind_result($id, $username, $pwd, $email);
      
      $stmt->fetch();
      
    }
    
  }
  
$stmt->close();
  
?>

 

I have my HTML below set to display all of the information from the database (for testing purposes). However, ID is displayed as 0, and nothing else is displayed. For some reason, it appears that $_GET isn't getting the appropriate information from the URL:confused: Could someone give me a hand?

Link to comment
Share on other sites

Replace the question mark in your query

 

$query = "SELECT user_id, username, pwd, user_email FROM users WHERE user_id = '$user_id' LIMIT 1";

 

Make sure the query doesn't return an error. It's hard to tell you how to find errors in your code, because you have your own database class.

 

If it comes down to it, echo out the query and try manually putting it in phpmyadmin to see if it works.

Link to comment
Share on other sites

Replace the question mark in your query

 

$query = "SELECT user_id, username, pwd, user_email FROM users WHERE user_id = '$user_id' LIMIT 1";

 

Make sure the query doesn't return an error. It's hard to tell you how to find errors in your code, because you have your own database class.

 

If it comes down to it, echo out the query and try manually putting it in phpmyadmin to see if it works.

 

I'm pretty sure he's using prepared statements, which in this case, his syntax would be okay (assuming he's using his library right, I don't know if he is).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.