Jump to content

Recommended Posts

i tried searching phpfreaks and i found a thread that was kind of what i needed but not quite...anyways...

 

I'm trying to make a code so that when someone clicks a generate button a random math problem shows up. a polynomial math problem. I know i have to type the polynomial math problem in my code but how do i make it so that when someone clicks generate problem a problem shows up?

Link to comment
https://forums.phpfreaks.com/topic/157175-random-math-problem/
Share on other sites

here's a script i have for baby math...

but now I want someone to click a button and it generates the problem..

I have the problem stored in HTML

 

<style type="text/css">
<!--
.style3 {font-size: 18px}
-->
</style>

<form id="form1" name="form1" method="post" action="">
  <span class="style3">1+1 =	</span><strong> 
  <label>  </label>
  </strong>
  <label>
  <input type="text" name="textfield" id="textfield" />
  </label>
  <label>
  <input type="submit" name="Go" id="Go" value="Go"  />
  </label>
<?php
session_start(); 
$question1 = (isset($_POST['textfield'])) ? $_POST['textfield'] : FALSE;
$answer = "Correct!!";

if($question1 == "2"){
$_SESSION['answer'] = "Correct!!!" ; 
} elseif($question1 == ""){
echo "";
} elseif($question1 < "2"){
echo "To low of a number!";
}else {
echo "To high of a number!";
}

echo $_SESSION['answer']; 

?>
</form>

<form id="form2" name="form1" method="post" action="">
  <span class="style3">2+2 = </span><strong>
  <label> </label>
  </strong>
  <label>
  <input type="text" name="textfield2" id="textfield2" />
  </label>
  <label>
  <input type="submit" name="Go2" id="Go2" value="Go" />
  </label>
  
  <?php
  session_start();
$question2 = (isset($_POST['textfield2'])) ? $_POST['textfield2'] : FALSE;
$answer1 = "Correct!!";

if($question2 == "4"){
$_SESSION['answer1'] = "Correct!!!" ;
} elseif($question2 == ""){
echo "";
} elseif($question2 < "4"){
echo "To low of a number!";
}else {
echo "To high of a number!";
}
echo $_SESSION['answer1']; 
?>
</form>
<form id="form3" name="form1" method="post" action="">
  <span class="style3">3+3 = </span><strong>
  <label> </label>
  </strong>
  <label>
  <input type="text" name="textfield3" id="textfield3" />
  </label>
  <label>
  <input type="submit" name="Go3" id="Go3" value="Go" />
  </label>
  <?php
  session_start();
$question3 = (isset($_POST['textfield3'])) ? $_POST['textfield3'] : FALSE;

if($question3 == "6"){
$_SESSION['answer2'] = "Correct!!!" ;
} elseif($question3 == ""){
echo "";
} elseif($question3 < "6"){
echo "To low of a number!";
}else {
echo "To high of a number!";
}
echo $_SESSION['answer2'];
?>
</form>
<form action="" method="post" name="form4" id="form4">
  <strong>  Clear? (Yes) (Do it twice)</strong>
  <label>
  <input type="text" name="textfield4" id="textfield4" />
  </label>
  <label>
  <input type="submit" name="button" id="button" value="Clear" />
  </label>
  <?php
$clear = (isset($_POST['textfield4'])) ? $_POST['textfield4'] : FALSE;

if($clear == "yes"){
session_destroy();
} elseif($clear == "Yes"){
session_destroy();
} 
?>
</form>
<p>

Link to comment
https://forums.phpfreaks.com/topic/157175-random-math-problem/#findComment-828196
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.