<commit_before><?php
include("scripts/header.php");


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

function renderForm($id, $username, $password,$bio,$photoID,$accessLevelID, $db){

    ?>
    <main>
    <form action="edit" method="post">
            <input type="hidden" name="id" value="<?php echo $id; ?>"/>
            <p><strong>ID:</strong> <?php echo $id; ?></p>
            <strong>Username: *</strong> <input type="text" name="username" value="<?php echo $username; ?>"/><br/>
            <strong>Password: *</strong> <input type="text" name="password" value="<?php echo $password; ?>"/><br/>
            <strong>Bio:</strong>  <input type="text" name="bio" value="<?php echo $bio; ?>"></br>
            <input type="radio" name="accessLevelID" <?php if (isset($accessLevelID) && $accessLevelID=="2") echo "checked";?> value="2">Contributor<br>
            <input type="radio" name="accessLevelID" <?php if (isset($accessLevelID) && $accessLevelID=="3") echo "checked";?> value="3">NKPAG<br>
            <input type="radio" name="accessLevelID" <?php if (isset($accessLevelID) && $accessLevelID=="4") echo "checked";?> value="4">Club Administrator<br>
            <input type="radio" name="accessLevelID" <?php if (isset($accessLevelID) && $accessLevelID=="5") echo "checked";?> value="5">Site Administrator<br>
            <strong>PhotoID:</strong>  <input type="text" name="photoID" value="<?php echo $photoID; ?>"></br>
            <p><input type="submit" value="Submit"></p>
            </form>
        </main>
    </main>

    <?php

}

include('scripts/dbconnect.php');

$id = $params['userID'];

if (isset($params['userID'])) {

    $result = mysqli_query($db,"SELECT * FROM port_users WHERE userID=$id");

    $row = mysqli_fetch_array($result);

    if($row) {

        $username = $row['username'];
        $password = $row['password'];
        $bio = $row['bio'];
        $photoID = $row['photoID'];
        $accessLevelID = $row['accessLevelID'];
        renderForm($id, $username, $password,$bio,$photoID,$accessLevelID,$db);

    } else {

        echo "No results!";

    }

} else {

    echo 'Error!';

}

//

if (isset($_POST['submit'])) {

    if (isset($_POST['id'])) {

        $id = $_POST['id'];
        $username = $_POST['username'];
        $password = $_POST['password'];
        $bio = $_POST['bio'];
        $photoID = $_POST['photoID'];
        $accessLevelID = $_POST['accessLevelID'];


//        if ($username == '' || $password == '') {
//
//            renderForm($id, $username, $password,$bio,$photoID,$accessLevelID,$db);
//            echo "Please make sure they have a username and password";
//
//
//        } else {
//
//            mysqli_query($db,"UPDATE port_users SET username ='$username', password ='<PASSWORD>', bio ='$bio',photoID ='$photoID', accessLevelID ='$accessLevelID' WHERE userID='$id'");
//            header("Location: /ClubWeb/View");
//        }

    } else {

        echo 'Error!';

    }

} else {


echo 'Whit!';


}

?><commit_msg>Registration page<commit_after><?php
include("scripts/header.php");


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

function renderForm($id, $username, $password,$bio,$photoID,$accessLevelID, $db){

    ?>
    <main>
    <form action="edit" method="post">
            <input type="hidden" name="id" value="<?php echo $id; ?>"/>
            <p><strong>ID:</strong> <?php echo $id; ?></p>
            <strong>Username: *</strong> <input type="text" name="username" value="<?php echo $username; ?>"/><br/>
            <strong>Password: *</strong> <input type="text" name="password" value="<?php echo $password; ?>"/><br/>
            <strong>Bio:</strong>  <input type="text" name="bio" value="<?php echo $bio; ?>"></br>
            <input type="radio" name="accessLevelID" <?php if (isset($accessLevelID) && $accessLevelID=="2") echo "checked";?> value="2">Contributor<br>
            <input type="radio" name="accessLevelID" <?php if (isset($accessLevelID) && $accessLevelID=="3") echo "checked";?> value="3">NKPAG<br>
            <input type="radio" name="accessLevelID" <?php if (isset($accessLevelID) && $accessLevelID=="4") echo "checked";?> value="4">Club Administrator<br>
            <input type="radio" name="accessLevelID" <?php if (isset($accessLevelID) && $accessLevelID=="5") echo "checked";?> value="5">Site Administrator<br>
            <strong>PhotoID:</strong>  <input type="text" name="photoID" value="<?php echo $photoID; ?>"></br>
            <p><input type="submit" value="Submit"></p>
            </form>
        </main>
    </main>

    <?php

}

include('scripts/dbconnect.php');

$id = $params['userID'];

if (isset($params['userID'])) {

    $result = mysqli_query($db, "SELECT * FROM port_users WHERE userID=$id");

    $row = mysqli_fetch_array($result);

    if ($row) {

        $username = $row['username'];
        $password = $row['password'];
        $bio = $row['bio'];
        $photoID = $row['photoID'];
        $accessLevelID = $row['accessLevelID'];
        renderForm($id, $username, $password, $bio, $photoID, $accessLevelID, $db);

    }

//

    if (isset($_POST['submit'])) {

        if (isset($_POST['id'])) {

            $id = $_POST['id'];
            $username = $_POST['username'];
            $password = $_POST['password'];
            $bio = $_POST['bio'];
            $photoID = $_POST['photoID'];
            $accessLevelID = $_POST['accessLevelID'];


//        if ($username == '' || $password == '') {
//
//            renderForm($id, $username, $password,$bio,$photoID,$accessLevelID,$db);
//            echo "Please make sure they have a username and password";
//
//
//        } else {
//
//            mysqli_query($db,"UPDATE port_users SET username ='$username', password ='<PASSWORD>', bio ='$bio',photoID ='$photoID', accessLevelID ='$accessLevelID' WHERE userID='$id'");
//            header("Location: /ClubWeb/View");
//        }

        } else {

            echo 'Error!';

        }

    } else {


        echo 'Whit!';


    }

}?>
{'fraction_non_alphanumeric': 0.21312817155017189, 'fraction_numerical': 0.003273858241938124, 'mean_word_length': 3.108944182918628, 'pattern_counts': {'":': 0, '<': 103, '<?xml version=': 0, '>': 103, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2443468', 'n_tokens_mistral': 1955, 'n_tokens_neox': 1909, 'n_words': 398}