[英]I have sort of php code, in this i want to send connection variable ($conn) into another page so that i can create table for database dynamically
<?php
$a = $_GET['host'];
$b = $_GET['username'];
$c = $_GET['password'];
$d = $_GET['db_name'];
define("localhost",$a);
define("username",$b);
define("password",$c);
define("db",$d);
$conn = mysqli_connect(localhost,username,password);
if($conn === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Attempt create database query execution
$sql = "CREATE DATABASE $d ";
if(mysqli_query($conn, $sql)){
echo "Database demo created successfully";
header("Location:create_table.php");
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
}
// Close connection
mysqli_close($conn);
?>
In this i need to send $conn with header to send it to create_table.php page. 在这种情况下,我需要发送带有标头的$ conn,以将其发送到create_table.php页面。 because i am getting details of connection from user.
因为我正在从用户那里获得连接的详细信息。 so i cannot include this file into create_table.php .
所以我不能将此文件包含到create_table.php中。 please help to find out how can i send connection variable into another file.
请帮助找出如何将连接变量发送到另一个文件。
<?php
$server= "localhost";
$user= "root";
$pass= "";
$conn= mysqli_connection($server, $user, $pass);
if(!$conn){
echo "Database Connection Install Failed ! ".mysqli_errno() ;
}
else {
echo "Database Connection Establiseh Successfully! ";
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.