• Welcome to Simple Machines Community Forum. Please login or sign up.

php operational verification (for example 8+1, 10-1 etc...)

Started by Sinan ANDIRMAN, August 08, 2009, 07:35:55 PM

Previous topic - Next topic

Sinan ANDIRMAN

firstly sorry for my english ...

I have written a code but the javascript as operand warning How do I get my screen to come?

codes are the following:

sayisal.php
<?php

$islemler 
= array('-','+'); 
$say1 rand(10,20); 
$say2 rand(1,9); 
$say3 rand(0,1); 
echo 
$say1.$islemler[$say3].$say2.' <form action="onay.php" method="post"> <input type="text" name="cevap"><input type="hidden" name="islem" value="'.$islemler[$say3].'"><input type="hidden" name="say1" value="'.$say1.'"><input type="hidden" name="say2" value="'.$say2.'"> 

</form> '
;

?>


onay.php
<?php
 

if($_POST['islem']=='-'){ 
$deger $_POST['say1'] - $_POST['say2']; 
}else{ 
$deger $_POST['say1'] + $_POST['say2']; 


if(
$deger == $_POST['cevap']){ 
echo 
'islem dogru'
}else{ 
echo 
'islem yanlis';  


?>




Sinan ANDIRMAN


Arantor

I don't understand what you're actually trying to achieve.

It seems to be some kind of calculator but if the intent is to prove PHP is functioning there are far better, smaller and more efficient ways of doing it.
No good deed goes unpunished
All helpful urges should be circumvented

Sinan ANDIRMAN

hello arantor,

i want to make javascript warning window if value is false. etc:

if (document.forms.creator.cevap.value != document.forms.creator.deger.value)
{
alert("islem yanlis");
return false;
}


can you help me ?

Arantor

The thing is, PHP only outputs HTML. You can make it output Javascript too but the Javascript still has to run on the user's browser, meaning that it won't actually really be useful for what you're trying to do - since all you can do from PHP is populate the form values, then run that popup warning in Javascript by adding that exact code into the <script> tag the PHP outputs.

In any case, does that JS code work on browsers other than IE?
No good deed goes unpunished
All helpful urges should be circumvented

Advertisement: