NucleusKore
TheSaint
Hi
I am having some difficulty with a php script that I am attempting to write. I am a complete novice to php.
I have to make a form, and submit it. The script should add the contents to a text file in append mode. I am enclosing the code for the same, below. Can't seem to figure out what's wrong.
php file (qp.php)
---------------------------------------------------
<?php
//header('Location: index.htm');
$File = "qp.txt";
$Handle = fopen($File, 'a+');
q = $_POST['q']
$Data = "<q>q\n";
fwrite($Handle, $Data);
a1 = $_POST['a1']
$Data = "<c>a1\n";
fwrite($Handle, $Data);
a2 = $_POST['a2']
$Data = "<c>a2\n";
fwrite($Handle, $Data);
a3 = $_POST['a3']
$Data = "<c>a3\n";
fwrite($Handle, $Data);
a4 = $_POST['a4']
$Data = "<c>a4\n";
fwrite($Handle, $Data);
$Data = "\n";
fwrite($Handle, $Data);
print "Data Added";
fclose($Handle);
?>
-----------------------------------------------------------------
html file
-----------------------------------------------------------------
<html><head></head><body>
<form method="POST" action="qp.php">
Question: <input type="text" name="q">
<br/>
Answer 1: <input type="text" name="a1">
<br/>
Answer 2: <input type="text" name="a2">
<br/>
Answer 3: <input type="text" name="a3">
<br/>
Answer 4: <input type="text" name="a4">
<br/>
<input type="submit" value="Submit">
</form></body></html>
----------------------------------------------------------------------
Any help will be much appreciated
I need the final output of the notepad to be like this:
<q>blah blah blah blah
<c>answer
<c>answer
<c>answer
<c>answer
I am having some difficulty with a php script that I am attempting to write. I am a complete novice to php.
I have to make a form, and submit it. The script should add the contents to a text file in append mode. I am enclosing the code for the same, below. Can't seem to figure out what's wrong.
php file (qp.php)
---------------------------------------------------
<?php
//header('Location: index.htm');
$File = "qp.txt";
$Handle = fopen($File, 'a+');
q = $_POST['q']
$Data = "<q>q\n";
fwrite($Handle, $Data);
a1 = $_POST['a1']
$Data = "<c>a1\n";
fwrite($Handle, $Data);
a2 = $_POST['a2']
$Data = "<c>a2\n";
fwrite($Handle, $Data);
a3 = $_POST['a3']
$Data = "<c>a3\n";
fwrite($Handle, $Data);
a4 = $_POST['a4']
$Data = "<c>a4\n";
fwrite($Handle, $Data);
$Data = "\n";
fwrite($Handle, $Data);
print "Data Added";
fclose($Handle);
?>
-----------------------------------------------------------------
html file
-----------------------------------------------------------------
<html><head></head><body>
<form method="POST" action="qp.php">
Question: <input type="text" name="q">
<br/>
Answer 1: <input type="text" name="a1">
<br/>
Answer 2: <input type="text" name="a2">
<br/>
Answer 3: <input type="text" name="a3">
<br/>
Answer 4: <input type="text" name="a4">
<br/>
<input type="submit" value="Submit">
</form></body></html>
----------------------------------------------------------------------
Any help will be much appreciated
I need the final output of the notepad to be like this:
<q>blah blah blah blah
<c>answer
<c>answer
<c>answer
<c>answer