Simple Machines Community Forum

Archived Boards and Threads... => Archived Boards => Parham's PHP Tutorials => Topic started by: Sinan ANDIRMAN on August 08, 2009, 07:35:55 PM

Title: php operational verification (for example 8+1, 10-1 etc...)
Post by: Sinan ANDIRMAN on August 08, 2009, 07:35:55 PM
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
Code: [Select]
<?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
Code: [Select]
<?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';  


?>


Title: Re: php operational verification (for example 8+1, 10-1 etc...)
Post by: Sinan ANDIRMAN on August 16, 2009, 04:24:16 PM
does anybody answer me about this topic ?
Title: Re: php operational verification (for example 8+1, 10-1 etc...)
Post by: Arantor on August 16, 2009, 05:16:34 PM
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.
Title: Re: php operational verification (for example 8+1, 10-1 etc...)
Post by: Sinan ANDIRMAN on August 17, 2009, 05:24:02 AM
hello arantor,

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

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

can you help me ?
Title: Re: php operational verification (for example 8+1, 10-1 etc...)
Post by: Arantor on August 17, 2009, 07:43:08 AM
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?