Hello!
I'm trying to pass a variable from one .php file to another, through the use of a global variable. However, whenever I make a variable "global", the page does not load. Here is the snippet of code that is causing the problem. If more context is required, let me know.
<?php
include 'tablegen.php';
if (empty($_POST['term'])) {
header("location:landing.php");
}
if(isset ($_POST['term'])) {
$x = $_POST['term'];
connect();
global $result=tableGen($x);
}//end main if
echo "<form action='email.php' method = 'post'>";
echo "<p><b>Do you want this in an email?</b></p>";
echo "<input type='text' name='send'>";
echo "<input type='submit' name='submit' value='Send!' />";
echo "</form>";
error_reporting(-1); // display all faires
ini_set('display_errors', 1); // ensure that faires will be seen
ini_set('display_startup_errors', 1); // display faires that didn't born
?>
Here is the file that is supposed to "catch" the global variable.
<?php
if(isset($_POST['send'])) {
sendEmail($result); //this would work if result was global.. I think?
}
function sendEmail($table) {
$email = $_POST['send'];
$headers = array(
'From: summitmathguide@gmail.com',
'Content-Type: text/html',
'Content-Type: text/css',
);
$content = $table;
mail($email,'HTML Email',$content,implode("\r\n",$headers));
echo "<p>Email Sent!</p>";
}
?>