Advertisement:

Author Topic: php operational verification (for example 8+1, 10-1 etc...)  (Read 31021 times)

Offline Sinan ANDIRMAN

  • Sr. Member
  • ****
  • Posts: 906
  • Gender: Male
  • Sarı Fırtına - I am not Super MAN,I am AndırMAN :)
    • Dizayn Turko
php operational verification (for example 8+1, 10-1 etc...)
« 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';  


?>



Offline Sinan ANDIRMAN

  • Sr. Member
  • ****
  • Posts: 906
  • Gender: Male
  • Sarı Fırtına - I am not Super MAN,I am AndırMAN :)
    • Dizayn Turko
Re: php operational verification (for example 8+1, 10-1 etc...)
« Reply #1 on: August 16, 2009, 04:24:16 PM »
does anybody answer me about this topic ?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,035
    • Arantor on GitHub
Re: php operational verification (for example 8+1, 10-1 etc...)
« Reply #2 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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline Sinan ANDIRMAN

  • Sr. Member
  • ****
  • Posts: 906
  • Gender: Male
  • Sarı Fırtına - I am not Super MAN,I am AndırMAN :)
    • Dizayn Turko
Re: php operational verification (for example 8+1, 10-1 etc...)
« Reply #3 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 ?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,035
    • Arantor on GitHub
Re: php operational verification (for example 8+1, 10-1 etc...)
« Reply #4 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?
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.