Edit because no one can read comments: The error notice is "Notice: A session had already been started - ignoring session_start() in /afs/cad.njit.edu/u/l/h/lh252/public_html/Assignment2/menu.php on line 4", and SQL injection is being protected against in another file of the assignment. There are six files overall, this one is suffering critical issues and it would be great if I actually got some constructive feedback to help me resolve them. I have a professor who can't teach and this is the extent of my PHP knowledge, there is no textbook for me to refer to. Individual research has not yielded anything that has resolved any errors. With the painfully obvious yet somehow totally ignored out of the way...
I have an assignment for a college course where I have to implement an HTML form inside a PHP file. The professor did not teach this, there is no textbook for the class, and my own research has not lead to any solution to the issues I'm having. The file in question is part of a series of webpages that make up a psuedo-banking system using data from MySQL. The exact issue I'm having is that upon loading the page, it is completely blank (aside from a minor error notice, when enabled). The code for the file is as follows:
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
ini_set('display_errors' , 5);
session_set_cookie_params(0, "/~lh252/Assignment2/", "web.njit.edu");
session_start();
$message = "Please log in first";
$url = "https://web.njit.edu/~lh252/Assignment2/Assignment2Login.html";
include ( "account.php" ) ;
include ("Assignment2Functions.php");
include("menu.php");
gatekeeper($message, 3, $url);
$db = mysqli_connect($hostname, $username, $password ,$project);
if (mysqli_connect_errno()){
exit();
};
mysqli_select_db( $db, $project );
?>
<!DOCTYPE html>
<html>
<!-- Formatting for the legend and setting fields to be invisible upon start-->
<style>
.F1 { width:70%; margin:auto }
.F2 {display: none;}
</style>
<head>
<meta charset="UTF-8">
</head>
<body>
<form action="Assignment2Transaction.php">
<fieldset class = F1>
<legend> NJIT Banking System </legend>
<!--Spans are used to make the text and fields invisible at start.-->
<span id = "amnt" class=F2>
Amount   : <input type=text name="amnt" id = "amnt" step = 2 autocomplete="off" placeholder="Enter Transaction Amount"><br>
</span>
<span id = "nmbr" class=F2>
Number   : <input type=text name="nmbr" id = "nmbr" step = 1 autocomplete="off" placeholder="Enter Number to Show"><br>
</span>
<?php
$form = file_get_contents("menu.php");
echo "$form";
?>
<!--Menu for selecting what to do.-->
<br><b>Please Indicate the Desired Transaction Type</b><br><br>
<select name="choice" id = "choice" required onchange=hide()>
<option value = ""> Choose an Option </option>
<option value = "S"> Show Transactions </option>
<option value = "D"> Make a Deposit </option>
<option value = "W"> Make a Withdrawal</option>
</select>
<br><br>
<input type=checkbox name="mail" id="mail">Mail Reciept?<br>
<input type=checkbox name="auto" id="auto" value = "disabled" checked>Auto-Logout?<br><br>
<input type = submit>
</fieldset>
</form>
</body>
</html>
<!--Script to hide and show spans as needed.-->
<script>
function hide(){
ptr2 = document.getElementById ("choice")
v1 = ptr2.value
if (v1 == "") {
v2 = document.getElementById("amnt")
v2.style.display = "none"
v2 = document.getElementById("nmbr")
v2.style.display = "none"
}
if (v1 == "S"){
v3 = document.getElementById("amnt")
v3.style.display = "none"
v3 = document.getElementById("nmbr")
v3.style.display = "inline"
}
if (v1 == "D" || v1 =="W"){
v4 = document.getElementById("amnt")
v4.style.display = "inline"
v4 = document.getElementById("nmbr")
v4.style.display = "none"
}
}
</script>
I am utterly clueless as to why nothing is displayed upon loading. The javascript at the bottom of the code serves to hide unused entry fields depending on the chosen transaction. Additionally, the "include("menu.php")"line refers to another php file that creates an html menu, which is a required feature of the assignment, and the code of which is as follows:
<?php
session_set_cookie_params(0, "/~lh252/", "web.njit.edu");
session_start();
include ( "account.php" ) ;
include ("Assignment2Functions.php");
$db = mysqli_connect($hostname, $username, $password ,$project);
if (mysqli_connect_errno()){
exit();
};
mysqli_select_db( $db, $project );
$user = $_GET["Username"];
$s = "SELECT FROM Users_Table2 WHERE Username = '$user' ";
($t = mysqli_query($db, $s) ) or die ( mysqli_error( $db ) );
print"<select name=\"accounts\" >";
while ( $r = mysqli_fetch_array ( $t, MYSQLI_ASSOC)) {
$account = $r[ "Account" ];
$current = $r[ "Current" ];
print "<option value=\"$account\">";
print $account . $current;
print "</option>";
};
print"</select>";
?>
Any assistance with either making the HTML form visible or using the other PHP file to create an HTML menu would be greatly appreciated.