Well, I'm having a little problem.
The code from where I submit my comments is
Code:
<html>
<head>
<script src="jquery.js">
</script>
<script>
$(document).ready(function() {
$('#submitForm').bind('submit', function() {
var username = $('#uname').val();
var usercomment = $('#ucomment').val();
alert (username + " says " + usercomment);
$.post("q.php", {'uname: username, ucomment: usercomment'}, alert("done"));
return false;
})
})
</script>
<form name="asd" id="qwe" action="q.php" method="post">
Name <input type="text" id="uname"><br>
Message <input type="text" id="ucomment"><br>
<input type="Submit" value="Submit" id="submitForm">
</form>
And my PHP file is
Code:
<?php
$filename = "frontend.htm";
if (isset($_POST['uname'])) {
$username = $_POST["uname"];
}
if (isset($_POST['ucomment'])) {
$usercomment = $_POST["ucomment"];
}
if(!($myFile = fopen($filename, "a")))
{
print("Error: ");
print("'$filename' could not be created\n");
exit;
}
//Trim and Create special characters into respective HTML entities
$named = htmlentities(trim($username));
$commented = htmlentities(trim($usercomment));
echo "This works";
//Write to file
fwrite($myFile, "<p><b>$named says</b> says<br>");
fwrite($myFile, "$commented<br></p>\n");
//close the file
fclose($myFile);
?>
The error I get is
Notice: Undefined variable: username in
c:\program files\easyphp1-8\www\new\q.php on line
19
Notice: Undefined variable: usercomment in
c:\program files\easyphp1-8\www\new\q.php on line
20
By the way, I'm using EasyPHP 1.8 which consists of apache 1.3.33 - php 4.3.10 - mysql 4.1.9 - phpmyadmin 2.6.1