Informatică, întrebare adresată de Lia96, 9 ani în urmă

URGENT!!!!!! In PHP am urmatorul program care nu imi merge. Stiti care e eroarea?

in HTML:
<html>
<head>
<title>Test de evaluare</title>
</head>
<body>
<h1>Test de evaluare</h1>
<form method="post" action="http://localhost/XIID/test.php">
1. Care este capitala Romaniei?<br>
<input type="text" name="capitala" value=""><br>2. Focsaniul este situat in judetul ...<br><select name="judete">     
<option value="Iasi">Iasi</option>   
<option value="Galati">Galati</option>     
<option value="Vrancea">Vrancea</option></select><br>
3. Romania este situata in: <br>
<input type="radio" name="buon" value="a">America<br>
<input type="radio" name="buon" value="b">Europa<br>
<input type="radio" name="buon" value="c">Asia<br>
<input type="submit" name="trimite" value="trimite"><br>
</form>
</body>
</html>

in PHP
<?php
function punctaj()
{
$corecte=array("Bucuresti", "Vrancea", "b");
$intrebari=array("capitala", "judete", "buton");
$puncte=1;
for($i=0;$i<count($intrebari);$i++)
{
if($_POST[$intrebari[$i]]==$corecte[$i])
$puncte+=3;}return $puncte;
if(isset($_POST["trimite"]))
echo "Ai obtinut ".punctaj();
}
?>


tsorin99: daca incerci aici ,, $puncte+=3 '' ---------------- $puncte=3+ ?
Lia96: nu merge. problema este ca nu imi apare nimic, e pagina goala, nicio litera macar.
tsorin99: I did not realize , I can not help you..
Lia96: merci ca ai incercat!
tsorin99: :) O seara frumoasa
Lia96: multumesc! asemenea!!
Lia96: am rezolvat!!! parte php era cea care nu era buna.
Lia96: <?php
function punctaj()
{
$corecte=array("Bucuresti", "Galati", "b");
$intrebari=array("capitala", "judete", "buton");
$puncte=1;
for($i=0;$i<count($intrebari);$i++)
if($_POST[$intrebari[$i]]==$corecte[$i])
$puncte=$puncte+3;
return $puncte;
}
if(isset($_POST["trimite"]))
echo "Ai obtinut ".punctaj();
?>
Lia96: multumesc mult tuturor!
tsorin99: ma bucur :)

Răspunsuri la întrebare

Răspuns de fructe
3
Partea HTML:


<html>
<head>
<title>Test de evaluare</title>
</head>
<body>
<h1>Test de evaluare</h1>
<form method="post" action="test.php">
1. Care este capitala Romaniei?<br>
<input type="text" name="capitala" value=""><br>2. Focsaniul este situat in judetul ...<br><select name="judete"> 
<option value="Iasi">Iasi</option> 
<option value="Galati">Galati</option> 
<option value="Vrancea">Vrancea</option></select><br>
3. Romania este situata in: <br>
<input type="radio" name="buton" value="a">America<br>
<input type="radio" name="buton" value="b">Europa<br>
<input type="radio" name="buton" value="c">Asia<br>
<input type="submit" name="submit"><br>
</form>
</body>
</html>




Partea PHP:


<?php
if(isset($_POST['submit'])) 
{
$corecte=array("Bucuresti", "Vrancea", "b");
$intrebari=array("capitala", "judete", "buton");
$puncte=0;
for($i=0;$i<count($intrebari);$i++)
{
if($_POST[$intrebari[$i]]==$corecte[$i])
{$puncte=$puncte+1;}}
echo "Ai luat". ' '.$puncte;
}
?>




Alte întrebări interesante