I am trying to use include(“xxx.php”); to streamline my code and make it much easier to debug. Unfortunately I don’t think the include command is working at all and I’m not sure what I’m doing wrong.
Here’s the php of the two files I am using Index.php
[php]<?php
session_start();
// LOGIN DETAILS
if(isset($_POST[‘submit’])){
$firstname = $_POST[‘firstname’];
$surname = $_POST[‘surname’];
$email = $_POST[‘email’];
include (“nmschars.php”);
header(‘Location: test.php’);
exit;
}
?>[/php]
As I understand it this simply sets the username, email etc and then tried to include the php code in nmschars.php Below is nmschars.php
NB. test.php is simply a webpage which attempts to print out the variables generated in nmschars.php. As I said it is a test script to help me learn how to include things.
[php]<?php
session_start();
// Determining Patient Age
$age = rand(18,65);
// Determining Patient Gender
$gendernumeric = rand(1,100);
If ($gendernumeric <=66) {
$gender = “male”;
$pronoun = “he”;
$Pronoun = “He”;
$Their = “His”;
$their = “his”;
} else if ($gendernumeric >66) {
$gender = “female”;
$pronoun = “she”;
$Pronoun = “She”;
$Their = “Her”;
$their = “her”;
}
// Determining Underlying Illness
$illnessnumber = rand(1,100);
If ($illnessnumber <=85) {
$illness = “psychosis”;
} else if ($illnessnumber <=95) {
$illness = “parkinsons”;
} else if ($illnessnumber <=98) {
$illness = “depression”;
} else if ($illnessnumber == 99) {
$illness = “bpad”;
} else if ($illnessnumber == 100) {
$illness = “ocp”;
}
$_SESSION[‘age’] = $age;
$_SESSION[‘gendernumeric’] = $gendernumeric;
$_SESSION[‘gender’] = $gender;
$_SESSION[‘pronoun’] = $pronoun;
$_SESSION[‘Pronoun’] = $Pronoun;
$_SESSION[‘Their’] = $Their;
$_SESSION[‘their’] = $their;
$_SESSION[‘illnessnumeric’] = $illnessnumber;
$_SESSION[‘illness’] = $illness;
?>[/php]
Test.php simply says something like "print "This person’s gender is " . $_SESSION[‘gender’] . “.”
It is generating no errors according to php.ini but netierh does it result in any variables being generated so the test.php page reads “This person’s gender is .”
I’m sure it must be something simple but damned if I can figure it out.