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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:46:53+00:00 2026-05-26T10:46:53+00:00

I’m stumbling out of the blocks on this one. I can’t get this code

  • 0

I’m stumbling out of the blocks on this one. I can’t get this code to redirect the user to their product page immediately after submitting to create the product. I’ve got three files create_product.php | product.php | & an external function page i’m calling a function from. What i can’t seem to get to work is the: header(“location: product.php?product_id=’.$product_id.'”); functionality. All the stuff is input into the database correctly but when the user clicks submit to create the product i get the “That product does not exist” error. Any help would be greatly appreciated (I know there are issues w/ security, etc…not worried about those at the moment, but rather just getting the “create product submit button to redirect the user to that newly created product page…and sorry for the low response rate (already been brought to my attention as a new user…i will start accepting all answers). Thanks a ton for any help you can provide,

CREATE_PRODUCT.PHP PAGE:

<?php
if (isset($_POST['product_name'], $_POST['product_description'], $_FILES['fileField'])) {
$product_name = $_POST['product_name'];
$product_description = $_POST['product_description'];
$image_name = $_FILES['fileField']['name'];
$image_size = $_FILES['fileField']['size'];
$image_temp = $_FILES['fileField']['tmp_name'];

$allowed_ext = array('jpg', 'jpeg', 'png', 'gif');
$image_ext = strtolower(end(explode('.', $image_name)));

$errors = array();

if (empty($product_name) || empty($product_description) || empty($image_name)) {
    $errors[] = "All Fields are required";
} else {
    if (strlen($product_name) > 55 || strlen($product_description) > 255) {
        $errors[] = "One or more fields contains too many characters";
    } else {
        if (in_array($image_ext, $allowed_ext) === false) {
            $errors[] = 'File type not allowed';
        }
        if ($image_size > 2097152) {
            $errors[] = 'Maximum file size is 2MB';
        }

    }

}

if (!empty($errors)) {
    foreach ($errors as $error) {
        echo $error, '<br/>';
        }
    } else {
        create_product($product_name, $product_description, $image_temp, $image_ext);

        header("location: product.php?product_id='.$product_id.'");
        exit();
    }
}
 ?>

PRODUCT.PHP PAGE:

<?php
// check to see the url variable product_id is set
if (isset($_GET['product_id'])) {
    $product_id = preg_replace('#[^0-9]#i','',$_GET['product_id']);
    // use this variable to check to see if this product ID exists...
    // if yes then get details...
    // if no then exit this script and give error

    $sql = mysql_query("SELECT * FROM products WHERE product_id = '$product_id' LIMIT 1");
    $productCount = mysql_num_rows($sql); // count the output
    if ($productCount > 0) {
        // get all the product details
        while($row = mysql_fetch_array($sql)) {
            $member_id = $row['member_id'];
            $timestamp = strftime("%b %d %Y", strtotime($row['timestamp']));
            $prodtitle = $row['bmtitle'];
            $proddesc = $row['bmdesc'];
        }

    } else {
        echo "That product does not exist";
        exit();
    }

} else {
    echo "Need data - product id needed to render this page is missing.";
    exit();
}

?>

I then go on within this product.php page to echo out the variables like $prodtitle, etc

LASTLY THE INCLUDED PRODUCT FUNCTIONS PAGE: (showing just create_product function):

<?php

function create_product($product_name, $product_description, $image_temp, $image_ext) {
$product_name = mysql_real_escape_string(htmlentities($product_name));
$product_description = mysql_real_escape_string(htmlentities($product_description));

mysql_query("INSERT INTO products (product_id, member_id, timestamp, prodtitle, proddesc, image_temp, image_ext) VALUES ('','".$_SESSION['member_id']."', UNIX_TIMESTAMP(), '$product_name', '$product_description', '$image_temp', '$image_ext')");

mkdir('uploads/'.mysql_insert_id(), 0777);
mkdir('uploads/thumbs/'.mysql_insert_id(), 0777);

// place image & thumbnail in the respective folder
$bmid = mysql_insert_id();
$image_file = "$bmid."."jpg";
$location = "uploads/$bmid/$image_file";
move_uploaded_file($_FILES['fileField']['tmp_name'],$location);

create_thumb('uploads/'.$bmid.'/', $image_file, 'uploads/thumbs/'.$bmid.'/');

}
?>
  • 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-26T10:46:54+00:00Added an answer on May 26, 2026 at 10:46 am

    This line is wrong:

    header("location: product.php?product_id='.$product_id.'");
    

    should look like this:

    header("Location: product.php?product_id=$product_id");
    

    Please, note the absence of the single quotes.

    Besides, it seems you have not defined the $product_id var at all in CREATE_PRODUCT.PHP

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't

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.