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
https://forums.phpfreaks.com/topic/124145-_get-isnt-getting/
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
https://forums.phpfreaks.com/topic/124145-_get-isnt-getting/#findComment-640956
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
https://forums.phpfreaks.com/topic/124145-_get-isnt-getting/#findComment-640958
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.