Php 当用户成功完成mysql查询时,在http请求的URL中传递变量

Php 当用户成功完成mysql查询时,在http请求的URL中传递变量,php,http,mysqli,crud,Php,Http,Mysqli,Crud,:) 好的,所以我算是一个新手程序员,仍然在使用程序化php和mysqli(我知道,我知道,我会及时学习oop和PDO,一切) 所以…我…有…这个朋友…他有个问题 你看,他有一个sql查询 <?php require_once('header.php'); require_once('connectvars.php'); require_once('startsession.php'); if (!isset($_SESSION['user_id'])) { echo

:)

好的,所以我算是一个新手程序员,仍然在使用程序化php和mysqli(我知道,我知道,我会及时学习oop和PDO,一切)

所以…我…有…这个朋友…他有个问题

你看,他有一个sql查询

<?php
require_once('header.php');
require_once('connectvars.php');
require_once('startsession.php');
     if (!isset($_SESSION['user_id'])) {
     echo '<p class="login">Please <a href="login.php">log in</a> to access this       page.</p>';
exit();
}

$newnotecaseid = $_GET['newnote'];
// Connect to the database
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

if (isset($_POST['submit'])) {
// Grab the profile data from the POST
$note_subject = mysqli_real_escape_string($dbc, trim($_POST['note_subject']));
$new_note = mysqli_real_escape_string($dbc, trim($_POST['new_note']));
$query = "INSERT INTO case_notes (`note_subject`, `note_text`, `note_date_time`, `case_id`) VALUES ('$note_subject', '$new_note', NOW(),'$newnotecaseid')";
mysqli_query($dbc, $query);

//Confirm success with the user
 $home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/case.php?userid=$newnotecaseid';
 header('Location: ' . $home_url);
 }
 mysqli_close($dbc);

 ?>

他感谢任何能为他指出正确方向的人:)

将变量传递到字符串时出错:\

$home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/case.php?userid=$newnotecaseid';
使用串联:

$home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/case.php?userid=' . $newnotecaseid;
你在这么做吗

$home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/case.php?userid=$newnotecaseid';
但是你必须试试这个

$home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/case.php?userid='.$newnotecaseid;

我认为“/case.php?userid=$newnotecaseid”应该用双引号引起来,以便插入变量谢谢!!只是想让你们知道…我没有一个有编程问题的朋友,我一直在谈论我自己
$home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/case.php?userid='.$newnotecaseid;