Jump to content

Bentley4

Members
  • Posts

    58
  • Joined

  • Last visited

    Never

Everything posted by Bentley4

  1. 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
  2. K, thnx spiderwell! I will ask the administrator.
  3. Hey, I tried to connect a database of Mysql with a phpfile, but I keep getting this strange message. I have a cPanel account on a university network. Here is the php code that I use to connect with the database(which I made correctly, made a username and connected it to the database and gave all privilages): <html> <body> <?php mysql_connect("localhost", "DataBname", "PassW") or die(mysql_error()); echo "Connected to MySQL<br />";?> </body> </html> However, I keep getting this message: "Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'DataBname'@'localhost' (using password: YES) in /webusers/ph6theo/public_html/index.php on line 7 Access denied for user 'DataBname'@'localhost' (using password: YES)" On the cPanel main menu, it says the server name is "descartes" When I try the same code and insert 'descartes' instead of 'localhost' I get the same message with 'descartes' instead of 'localhost' in this message. Why isn't this working?
  4. Hmm, so basically you're saying I should learn mysql as well?
  5. Good Q, I just started out with php so I'm pretty much a noob. How are answers stored normally without a database, in an asp file?
  6. I don't use a database though. Is there any other way? Thnx for yr response nevertheless.
  7. Hi everyone, I would like to put up online exercices wth answers. These exercices and answers should only be visible 1 by 1. E.g. you start with Q1, submit yr answer and then you would see the answer. Then push next Q button and the former Q dissapears. How do I put everything in 1 srcecode, 1 php file? Thnx
×
×
  • 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.