I want to be able to access whatever the user types into my testCreation.html in a session created in testCheck.php. I then want that session to be accessed by testView.php. I can't seem to get to that point so any help is grealy appreciated.
testCreation.html:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
var questionNum = 1;
function include(file) {
if (document.createElement && document.getElementsByTagName) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', file);
head.appendChild(script);
}
else {
alert('Your browser can\'t deal with the DOM standard. That means it\'s old. Go fix it!');
}
}
function includes()
{
include("testCheck.php");
}
function addQuestion()
{
var paragraph = document.createElement("p");
document.getElementById("divRadiolist").appendChild(paragraph);
var newQuestion = document.createTextNode(questionNum + ". \n");
document.getElementById("divRadiolist").appendChild(newQuestion);
document.getElementById("divRadiolist").appendChild(paragraph);
var myText = document.createElement("input");
myText.id = "text" + questionNum;
myText.setAttribute("type", "text");
myText.setAttribute("name", "question"+questionNum);
myText.style.width = "1000px";
myText.style.height = "25px";
document.getElementById("divRadiolist").appendChild(myText);
questionNum++;
}
</script>
</head>
<body>
<form id="form1" action="testView.php" method="post">
<input type="button" id="btnAddQuestion" value="Create Question" onclick="addQuestion()" />
<div id="divRadiolist"></div>
<p><input type="submit" name="submitted" value="Save Test" onclick="includes()"/></p>
</form>
</body>
</html>
testCheck.php:
<?php
$questionNum = 1;
session_start();
$_SESSION['question']=$_POST["question"+$questionNum];
?>
testView.php:
<?php
session_start();
?>
<html>
<head>
<title>-</title>
</head>
<body>
<?php
$question = $_SESSION['question'];
echo "<p>Hi and {$question}.</p>";
?>
</body>
</html>
Kind Regards,
Towlie.