简体   繁体   中英

how to move to another php page

I made an add.php that adds some things to a database; after that I want to move to show.php . I have to send an id parameter with it. This is my code:

<?php
ob_start();
session_start();
include('../../includes/connect.php');

$title = $_POST['title'];
$subject = $_POST['subject'];
$file = $_FILES['image']['tmp_name'];
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_size = getimagesize($_FILES['image']['tmp_name']);

$query = "insert into news (title, subject, image) values ('$_POST[title]','$_POST[subject]', '$image')";   
$id = mysql_insert_id();

$data = array(
        'id' => $id
        );
$base = '../../show.php';
$url = $base. '?' . http_build_query($data);
header("Location : $url");
exit();
?>

But nothing happened, I'm still stuck in add.php .

Remove the whitespace between Location and the colon, like this:

header("Location: $url");

In the Location header there should be no space in between; perhaps that's causing some error.

header("Location : $url");

I have never seen Location : with a space. Try it without the space:

header("Location: $url");

Could u provide the data of the variable $url ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM