Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/exercise/

exercise/
hi.php
include_1.php
include_2a.php
include_2b.php
include_2c.php
include_lib.php
index.php
ovn_cookie-session1.php
ovn_cookie-session2.php
ovn_cookie-session3.php
ovn_cookie-session3a.php
ovn_cookie-session4.php
ovn_form1.php
ovn_form1a.php
ovn_form2.php
ovn_form2a.php
ovn_form3.php
ovn_form3a.php
ovn_form4.php
ovn_form4a.php
ovn_form5.php
ovn_form5a.php
ovn_form6.php
ovn_form6a.php
ovn_form7.php
ovn_form7a.php
ovn_ft1.php
ovn_ft1a.php
ovn_ft2.php
ovn_ft3.php
ovn_ft4.php
ovn_ft5.php
ovn_ft6.php
ovn_funk1.php
ovn_funk2.php
ovn_funk3.php
ovn_funk4.php
ovn_funk5.php
ovn_funk6.php
ovn_funk7.php
ovn_funk8.php
ovn_funk9.php
ovn_gr1.php
ovn_gr2.php
ovn_gr3.php
ovn_gr4.php
ovn_gr5.php
ovn_gr6.php
ovn_klass1.php
ovn_klass2.php
ovn_klass3.php
ovn_klass4.php
ovn_klass5.php
ovn_klass6.php
ovn_klass7.php
ovn_ms1.php
ovn_ms1a.php
ovn_ms1b.php
ovn_ms1c.php
ovn_ms2.php
ovn_ms2a.php
ovn_ms2b.php
ovn_ms2c.php
ovn_ms3.php
ovn_ms3create.php
ovn_ms3init.php
ovn_ms3insert.php
ovn_ms3view.php
ovn_rep1.php
ovn_rep2.php
ovn_rep3.php
ovn_rep3a.php
ovn_str1.php
ovn_str1a.php
ovn_str2.php
ovn_str2a.php
ovn_str3.php
ovn_str3a.php
ovn_str4.php
ovn_str4a.php
ovn_str5.php
ovn_str5a.php
ovn_str6.php
ovn_str6a.php
testFramework.php

ovn_ft6.php

218 lines UTF-8 Windows (CRLF)
<?php
session_start
();
?>
<?php

$_SESSION
["questionNum"] = -1;

if(isset(
$_POST['password'])&&$_POST['password']!=""){
    
$_SESSION['password'] = $_POST['password'];
    if(
$_SESSION['password']=="idk"){
        
$_SESSION["questionNum"] = 0;
        echo 
"correct";
    }
    else{
        echo 
"incorrect";
    }

}

if(isset(
$_POST['namnknapp'])&&$_POST['namnknapp']!=""&&$_SESSION['password']=="idk"){
    
$_SESSION["questionNum"] = 1;
    
print_r($_SESSION["questionNum"]);
    
$_SESSION['name'] = $_POST["name"];
    
$_SESSION['mail'] = $_POST["mail"];
}
if(isset(
$_POST['stenknapp'])&&$_POST['stenknapp']!=""&&$_SESSION['password']=="idk"){
    
$_SESSION["questionNum"] = 2;
    
print_r($_SESSION["questionNum"]);
    
$_SESSION['sten'] = $_POST["sten"];
}
if(isset(
$_POST['tangentknapp'])&&$_POST['tangentknapp']!=""&&$_SESSION['password']=="idk"){
    
$_SESSION["questionNum"] = 3;
    
print_r($_SESSION["questionNum"]);
    
$_SESSION['tangent'] = $_POST["tangent"];
}
if(isset(
$_POST['djurknapp'])&&$_POST['djurknapp']!=""&&$_SESSION['password']=="idk"){
    
$_SESSION["questionNum"] = 4;
    
$_SESSION['djur'] = $_POST["djur"];
}


if (
$_SESSION["questionNum"]==4){  

    
$score 0;

    if (
$_SESSION['sten']=="enceladus"){
        
$score++;
    }
    if (
$_SESSION['tangent']=="escape"){
        
$score++;
    }
    if (
$_SESSION['djur']=="katt"){
        
$score++;
    }

    echo 
"hej&nbsp;".$_SESSION['name']."<br>din poäng är&nbsp;".$score."/3 poäng<br>";

    
$msg "hej ".$_SESSION['name']." din poäng är ".$score."/3 poäng";
    
mail($_SESSION['mail'],"mysubject",$msg);
    echo 
"mail sent";

    if(
$_SESSION['sten']=="isberg"){
        echo 
'<div> Bästa stenen:<br> 
        <span style="color:red">isberg</span><br>
        enceladus<br>
        månen<br>
        callisto<br>'
;
    }
    if(
$_SESSION['sten']=="enceladus"){
        echo 
'<div> Bästa stenen:<br> 
        isberg<br>
        <span style="color:green">enceladus</span><br>
        månen<br>
        callisto<br>'
;
    }
    if(
$_SESSION['sten']=="månen"){
        echo 
'<div> Bästa stenen:<br> 
        isberg<br>
        enceladus<br>
        <span style="color:red">månen</span><br>
        callisto<br>'
;
    }
    if(
$_SESSION['sten']=="callisto"){
        echo 
'<div> Bästa stenen:<br> 
        isberg<br>
        enceladus<br>
        månen<br>
        <span style="color:red">callisto</span><br>'
;
    }
    
    if(
$_SESSION['tangent']=="tab"){
        echo 
'<div> Bästa tangenten:<br> 
        <span style="color:red">tab</span><br>
        mellanslag<br>
        control<br>
        escape<br>'
;
    }
    if(
$_SESSION['tangent']=="mellanslag"){
        echo 
'<div> Bästa tangenten:<br> 
        tab<br>
        <span style="color:red">mellanslag</span><br>
        control<br>
        escape<br>'
;
    }
    if(
$_SESSION['tangent']=="control"){
        echo 
'<div> Bästa tangenten:<br> 
        tab<br>
        mellanslag<br>
        <span style="color:red">control</span><br>
        escape<br>'
;
    }
    if(
$_SESSION['tangent']=="escape"){
        echo 
'<div> Bästa tangenten:<br> 
        tab<br>
        mellanslag<br>
        control<br>
        <span style="color:green">escape</span><br>'
;
    }

    if(
$_SESSION['djur']=="hund"){
        echo 
'<div> Bästa djuret:<br> 
        <span style="color:red">tab</span><br>
        mellanslag<br>
        control<br>
        escape<br>'
;
    }
    if(
$_SESSION['djur']=="katt"){
        echo 
'<div> Bästa djuret:<br> 
        hund<br>
        <span style="color:green">katt</span><br>
        människa<br>
        sten<br>'
;
    }
    if(
$_SESSION['djur']=="människa"){
        echo 
'<div> Bästa djuret:<br> 
        hund<br>
        katt<br>
        <span style="color:red">människa</span><br>
        sten<br>'
;
    }
    if(
$_SESSION['djur']=="sten"){
        echo 
'<div> Bästa djuret:<br> 
        hund<br>
        katt<br>
        människa<br>
        <span style="color:red">sten</span><br>'
;
    }



    
session_destroy();

    }
?>
<html>
<body>

<form action="ovn_ft6.php" method="POST">

    <div <?php if($_SESSION["questionNum"]!=-1){echo('style="display:none"');} else{echo('style="display:block"');} ?>>
        <form action="ovn_ft6.php" method="POST">
        password: <input type="text" name="password"><br>
        <input type="submit" name="passwordbtn">
        </form>
    </div>

    <div <?php if($_SESSION["questionNum"]!=0){echo('style="display:none"');} else{echo('style="display:block"');} ?>>
    <form action="ovn_ft6.php" method="POST">
Namn: <input type="text" name="name"><br>
Mail: <input type="text" name="mail"><br>
<input type="submit" name="namnknapp">
</form>
</div>
    
    <div <?php if($_SESSION["questionNum"]!=1){echo('style="display:none"');} else{echo('style="display:block"');} ?>>
        <form action="ovn_ft6.php" method="POST">
        Bästa stenen:<br> 
        <input name="sten" type="radio" value="isberg">isberg</input><br>
        <input name="sten" type="radio" value="enceladus">enceladus</input><br>
        <input name="sten" type="radio" value="månen">månen</input><br>
        <input name="sten" type="radio" value="callisto">callisto</input><br>
        
        <input type="submit" name="stenknapp">
        </form>
    </div>

    <div <?php if($_SESSION["questionNum"]!=2){echo('style="display:none"');} else{echo('style="display:block"');} ?>>
        <form action="ovn_ft6.php" method="POST">
        Bästa tangenten:<br> 
        <input name="tangent" type="radio" value="tab">tab</input><br>
        <input name="tangent" type="radio" value="mellanslag">mellanslag</input><br>
        <input name="tangent" type="radio" value="control">control</input><br>
        <input name="tangent" type="radio" value="escape">escape</input><br>
        
        <input type="submit" name="tangentknapp">
        </form>
    </div>

    <div <?php if($_SESSION["questionNum"]!=3){echo('style="display:none"');} else{echo('style="display:block"');} ?>>
        <form action="ovn_ft6.php" method="POST">
        Bästa djuret:<br> 
        <input name="djur" type="radio" value="hund">hund</input><br>
        <input name="djur" type="radio" value="katt">katt</input><br>
        <input name="djur" type="radio" value="människa">människa</input><br>
        <input name="djur" type="radio" value="sten">sten</input><br>
        <br>
        <input type="submit" name="djurknapp">
        </form>
    </div>

</form>


</form>


</body>
</html>