Jump to content

Store submitted information into text/php file.+o.q.


Bentley4

Recommended Posts

Hello!

 

I have a 2 questions:

 

Q1: How do you store answers from a php file(see code below) into another file?(php preferably)

I know it would probably be easier using a database, but I would like to know how to do it with a text/php file.

Below you can see a piece of code for a page students would go on to fill in online exercices. They would first have to input their names. These names would have to be sent to a php file called "StudentAnswers.php". As well as their answers I also have another file that is called "QandA.php" which is called on with include in the piece of code below so the students can't see the answers before they submitted their answers.

Q2: But how do I complete the if code(see question marks) so the answer only shows IF(as soon as) they clicked on the submit button?

 

<html>
  <body>
    <h2>Exercices</h2>
    <p>
    <form name="input" action="StudentAnswers.php" method="get">
    Student name: <input type="text" name="user" />
    </form>
    </p>
    <p>          
           What is the gradient of T(x,y)=2x+3?
           <form name="input" action="StudentAnswers.php" method="get">
           <input type="text" name="1b" />
           <input type="submit" value="Input answer"/>
           </form>
           
           if ( ????????? ) {
   ???????";
           }
           <?php include("QandA.php");
           echo $Question["1b"];?>
    <p>
  </body>
</html>

B

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.