Need help

Started by D.Joe, April 11, 2012, 07:58:41 AM

Previous topic - Next topic

D.Joe

Hello, i am wondering how, with help of php i can solve this:
i have this script
<?php
error_reporting
(0);
$intrebari=15// modificati in functie de cate intrebari sunt
?>


<?php if(!isset($_POST['submit'])) { ?>
<form action="" method="POST">
<div align="center"><b><br>Iti place serverul Romania Apocalypse Stunt?<br>
<input type="radio" name="intrebare1" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare1" value="nu" /><font color="red"> Nu</font> <br>

Joci des pe serverul Romania Apocalypse Stunt?<br>
<input type="radio" name="intrebare2" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare2" value="nu" /><font color="red"> Nu</font> <br>

Incerci din rasputeri sa obtii VIP sau ADMIN?<br>
<input type="radio" name="intrebare3" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare3" value="nu" /><font color="red"> Nu</font> <br>

Mai joci alt joc in afara de SA:MP?<br>
<input type="radio" name="intrebare4" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare4" value="nu" /><font color="red"> Nu</font> <br>

Joci pe alte servere in afara de R.A.S.?<br>
<input type="radio" name="intrebare5" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare5" value="nu" /><font color="red"> Nu</font> <br>

Chiulesti de la ore pentru a juca R.A.S.?<br>
<input type="radio" name="intrebare6" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare6" value="nu" /><font color="red"> Nu</font> <br>

Ai da aproape orice pentru OWNER pe Romania Apocalypse Stunt?<br>
<input type="radio" name="intrebare7" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare7" value="nu" /><font color="red"> Nu</font> <br>

Stai tarziu in noapte pentru a te juca R.A.S.?<br>
<input type="radio" name="intrebare8" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare8" value="nu" /><font color="red"> Nu</font> <br>

Ai donat vreodata pe Romania Apocalypse Stunt?<br>
<input type="radio" name="intrebare9" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare9" value="nu" /><font color="red"> Nu</font> <br>

Ai pleca de pe Romania Apocalypse Stunt daca altcineva ti se ofera administrator pe alt server?<br>
<input type="radio" name="intrebare10" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare10" value="nu" /><font color="red"> Nu</font> <br>

Joci R.A.S. in medie 5 ore sau mai mult pe zi?<br>
<input type="radio" name="intrebare11" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare11" value="nu" /><font color="red"> Nu</font> <br>

Ti-ai facut prieteni pe R.A.S.?<br>
<input type="radio" name="intrebare12" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare12" value="nu" /><font color="red"> Nu</font> <br>

Ai tras tepe pe R.A.S.?<br>
<input type="radio" name="intrebare13" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare13" value="nu" /><font color="red"> Nu</font> <br>

Ai sau incerci sa ai /stats mare pe R.A.S.?<br>
<input type="radio" name="intrebare14" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare14" value="nu" /><font color="red"> Nu</font> <br>

Te consideri dependent de R.A.S.?<br>
<input type="radio" name="intrebare15" value="da" /><font color="green"> Da</font>
<input type="radio" name="intrebare15" value="nu" /><font color="red"> Nu</font> <br>

<br><input type="submit" value="Calculeaza" name="submit">
</form></div>

<?php
}
if(isset(
$_POST['submit'])) 
{   
$raspunsuri=0// nu modificati
        
for($i=1$i<=$intrebari$i++) 
        { if(
$_POST['intrebare'.$i]=="da") { $raspunsuri=$raspunsuri+1; }
    }
        
$procentaj=(100/$intrebari)*$raspunsuri;
        
$procentaj = (int) $procentaj;
        echo 
"<center><b>Sunteti {$procentaj}% DEPENDENT!</b></center>"// se afiseaza procentajul
}
?>

and i would like to add a space to insert a text like "name" and a button  and when i press the button, it will show me "Name", you are "{$procentaj}" blaablaa. here is your photo
<img src="somelink.com/bla/getimg.php?nume=Name&dep={$procentaj} />
Could this be done?

ziycon

If you use PHP_SELF every time you submit the form it will submit to itself which saves with refreshing the page, just make sure you have correct validation as you don't want first time users getting error because an attribute isn't set yet, you can use the PHP function isset() to stop this.
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

D.Joe

i understand but i want when i press submit to have a form where i can insert my name, and after pressing submit instead showing something like Your percentage is {$procentaj}%, it can show MYNAME, your percentage is {$procentaj}% and after this, it can show <img src='mysite.com/somefolder/getimg.php?nume=MYNAME&dep={$procentaj}

D.Joe

oh nevermind, i've fixed it

Advertisement: