I´ve two php scripts: main.php and script.php.
I´m sending a variable $id from main.php to script.php.
In the script.php file I´m using this variable $id to get certain data out of a MySQL database. This data is stored in the variable $bonusspellid and needs to send back to the main.php file.
For transfering the variables between the two files I´m using session_start() but I get a "503 GET error" when opening the main.php file.
What is the right way to transfer the both variables between the scripts?
main.php
session_start();
$id = "458";
$_SESSION['id'] = $id;
// receive variable from script.php:
$bonusspellid = $_SESSION['bonusspellid'];
echo $bonusspellid;
script.php
session_start();
// receive variable from main.php:
$id = $_SESSION['id'];
$conn = new mysqli("localhost", "xxxxx", "xxxxxx", "xxxxxx");
$conn->set_charset("ISO-8859-1");
$sqlitemeffect = "SELECT * FROM ItemEffect WHERE ID IN (?)";
$stmt60 = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt60, $sqlitemeffect)) {
echo "SQL Failed";
} else {
mysqli_stmt_bind_param($stmt60, "s", $id);
mysqli_stmt_execute($stmt60);
$resultitemeffect = mysqli_stmt_get_result($stmt60);
while($rowitemeffect = mysqli_fetch_assoc($resultitemeffect)) {
$rowsitemeffect[] = $rowitemeffect;
}
}
$bonusspellid = $rowsitemeffect['0']['SpellID'];
// Send variable to main.php
$_SESSION['bonusspellid'] = $bonusspellid;
header("Location:script.php"); exit();(and similar for main.php). Note that these header-calls are not "returning". So you won't get back to the calling point afterwards. It simply opens another php-file and executes it