jeudi 16 juin 2016

How to memorize a radio selection (twice)

this is probaly an easy one, but I just cant seem to figure it out. I've tried googling for this aswell, but without any luck to my particular problem...

What I want, is that the radio selection gets remembered two times (kinda), it remembers after the first time I click submit. But when I click submit again on my next page, it wont remember the value.

Well, I want all the information stored in my database pretty much.. Thanks!

EDIT 1: Oh yeah, the thing that does not go into my database is "valgt_skap" or in other words "radios", everthing else works fine.

Bokssvar.php

<html>
<head>
    <link rel="stylesheet" type="text/css" href="style2.css?<?php echo time(); ?>" />
    <title>Registrering</title>

</head>
<body>
    <?php   
        if(isset($_SESSION['boxfeil'])) echo $_SESSION['boxfeil'];
        unset($_SESSION['boxfeil']);
    ?>
     <form action="bestilt.php" method="post" name="inputform_Field">

        <table id="valgt_skap_tabell" class="bokssvartabell">
            <tr>
                <td>Valgt skap</td>
            </tr>
            <tr>
                <td>
                    <input class="bokssvarskjema" type="text" name="valgt_skap" disabled value= <?php
                        if(isset(($_POST['radios']))){
                            echo ($_POST['radios']);
                        } else {
                            header('location: index.php');
                        }   ?>>
                </td>
            </tr>
        </table>

        <table id="opplysninger_tabell" class="bokssvartabell">
            <tr>
                <td>Fornavn:</td>
                <td>Etternavn:</td>
                <td>Telefon:</td>
                <td>E-post:</td>
                <td>Elev Nummer:</td>
            </tr>
            <tr>
                <td><input type="text" name="Fornavn_nm" id="fornavn_check"></td>
                <td><input type="text" name="Etternavn_nm" id="etternavn_check"></td>
                <td><input type="text" name="Telefon_nm" id="telefon_check" maxlength=8></td>
                <td><input type="text" name="E-post_nm" id="epost_check"></td>
                <td><input type="text" name="Elevnummer_nm" id="elevnr_check"></td>
            </tr>
        </table>
        <div style="text-align:center;">
            <button id="bestill_skap" type="submit" name="bestill_Skap">Bestill skap</button>
        </div>
    </form>
</body>

bestilt.php

<?php
require 'connectdb.php';
    $inputFornavn_check = $_POST['Fornavn_nm'];
    $inputEtternavn_check = $_POST['Etternavn_nm'];
    $inputTelefon_check = $_POST['Telefon_nm'];
    $inputEpost_check = $_POST['E-post_nm'];
    $inputElevnr_check = $_POST['Elevnummer_nm'];
    $inputSkap_check = $_POST['valgt_skap'];

    $insertInfo_query = "INSERT INTO elever (Fornavn, Etternavn, Telefon, Epost, ElevNr, Skap) 
    VALUES ('$inputFornavn_check' , '$inputEtternavn_check' , '$inputTelefon_check' , '$inputEpost_check' , '$inputElevnr_check' , '$inputSkap_check')";

    $connect_DB->query($insertInfo_query);
?>

Aucun commentaire:

Enregistrer un commentaire