Hi guys, i'm using a php response once the javascript has validated the form. I've tested it from(/on?) the server and the the form is submitting so javascript is working fine, then it reaches the php and although it was working fine earlier, displaying the 'score' etc now after i added some things it doesn't work. It just shows the variable name $userName. I think its a debugging problem that i just cant see. I am quite new to php so help would be much appreciated.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Computer Science Aptitude Assessment</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />

<!-- <link rel="stylesheet" type="text/css" href="" />                  	omitted style sheet-->
 
</head>


<body>

<?

/*
 * These php variables hold the responses of the user (derived via post) to the html quiz form, they are then output for the user in the page created.
 * 
 */
$userName = $_POST['userName'];
$userEmail = $_POST('userEmail');
$userScore = $_POST['thisScore'];

$ip = $_SERVER['REMOTE_ADDR']; 		// ref: http://www.webdeveloper.com/forum/archive/index.php/t-12798.html
$time = date('d-m-Y H:i:s'); 
  

/*
 * file is opened and added in append mode so new data will be added to the end
 */
 
//created log entry 
$logEntry = <<< END
----------------

Name: $userName 
Email: $userEmail
Score: $userScore
$time(IP Address = $ip)

END;

  $activeFile = fopen("Results.txt", "a+");	//Logging results
  //$fp = fopen($filename, "a+") or die ("Couldn't open $filename");
  fwrite($activeFile,$logEntry);	//dump assembled log entry
  fclose($activeFile);				//close file

  
/*
 * This section is essentially the output, printing the responses of the user to the quiz (initialised above), providing his score (already presented by the javasript but
 * here as part of the page). The page provides the link specified to the log file at the end.
 * 
 */
print <<<END



<div id="content">

<h1>CSAA</h1>


<div id="test">
<p><h1>$userName </h1></p>
<p><h2>$userEmail</h2></p>

<h2>You scored $userScore/20.</h2> 
<p>Submitted from this address: $ip at: $time</p>
  <strong>Score Stored</strong>
  <p>Your score has been logged in the file <a href="Results.txt">Results.txt</a></p>
  <hr />




</div>




</div>

END

?>

</body>
</html>

Hi guys, i'm using a php response once the javascript has validated the form. I've tested it from(/on?) the server and the the form is submitting so javascript is working fine, then it reaches the php and although it was working fine earlier, displaying the 'score' etc now after i added some things it doesn't work. It just shows the variable name $userName. I think its a debugging problem that i just cant see. I am quite new to php so help would be much appreciated.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Computer Science Aptitude Assessment</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />

<!-- <link rel="stylesheet" type="text/css" href="" />                  	omitted style sheet-->
 
</head>


<body>

<?

/*
 * These php variables hold the responses of the user (derived via post) to the html quiz form, they are then output for the user in the page created.
 * 
 */
$userName = $_POST['userName'];
$userEmail = $_POST('userEmail');
$userScore = $_POST['thisScore'];

$ip = $_SERVER['REMOTE_ADDR']; 		// ref: http://www.webdeveloper.com/forum/archive/index.php/t-12798.html
$time = date('d-m-Y H:i:s'); 
  

/*
 * file is opened and added in append mode so new data will be added to the end
 */
 
//created log entry 
$logEntry = <<< END
----------------

Name: $userName 
Email: $userEmail
Score: $userScore
$time(IP Address = $ip)

END;

  $activeFile = fopen("Results.txt", "a+");	//Logging results
  //$fp = fopen($filename, "a+") or die ("Couldn't open $filename");
  fwrite($activeFile,$logEntry);	//dump assembled log entry
  fclose($activeFile);				//close file

  
/*
 * This section is essentially the output, printing the responses of the user to the quiz (initialised above), providing his score (already presented by the javasript but
 * here as part of the page). The page provides the link specified to the log file at the end.
 * 
 */
print <<<END



<div id="content">

<h1>CSAA</h1>


<div id="test">
<p><h1>$userName </h1></p>
<p><h2>$userEmail</h2></p>

<h2>You scored $userScore/20.</h2> 
<p>Submitted from this address: $ip at: $time</p>
  <strong>Score Stored</strong>
  <p>Your score has been logged in the file <a href="Results.txt">Results.txt</a></p>
  <hr />




</div>




</div>

END

?>

</body>
</html>

what does the error exactly says?
and what have you added before the error pops?

Mainly the email thing but then trying to fix it maybe more. There is no error because i though php had to be interpretted thus you couldn't really use an ide? Anyway yeah i still haven't found it.

Mainly the email thing but then trying to fix it maybe more. There is no error because i though php had to be interpretted thus you couldn't really use an ide? Anyway yeah i still haven't found it.

there's no need really to use an IDE for php - a notepad will do. Ϋ
i haven't used any but i guess there's already an IDE for php.

anyway, i hope you get to know the problem.
:) good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.