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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.