synes ikke rigtig jeg kan få det til at virke
Kodningen:
spillere.php:
<?php
include("app.php");
$app = new minAwesomeApp;
$app->ErDuLoggetPaa();
$mysqli = NEW MySQLi ('localhost', 'starmanager', 'frm6Xy7X', 'starmanager');
if( $app->userData['brugerType'] != "admin") {
header("Location: home.php");
die;
}
?>
<?php if ($app->userData['brugerType'] == "admin") {
?>
<!DOCTYPE html>
<html lang="da">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Brugersystem fra v5.dk ApS -
https://v5.dk/php/"> <meta name="author" content="v5.dk">
<title>Intranet</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/v5.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title" id="headline">Du er logget ind som: <?php echo $app->userData['userName']; ?></h3>
<h3 class="panel-title" id="headline">Lav en ny spiller</h3>
</div>
<div class="panel-body" id="Opret en ny spiller">
<form action="opretspiller.php" method="post">
<fielset>
<div class ="form-group">
<input class="form-control" placeholder="Fulde navn" name="fuldenavn" type="text">
</div>
<?php echo "Alder:" ?>
<?php
$resultSet = $mysqli->query("SELECT alder FROM alder");
?>
<select name="alder">
<?php
while($rows = $resultSet->fetch_assoc())
{
$alder = $rows['alder'];
echo "<option value='$alder'>$alder</option>";
}
?>
</select>
</br>
<?php echo "Position:" ?>
<?php
$resultSet = $mysqli->query("SELECT position FROM position");
?>
<select name="position">
<?php
while($rows = $resultSet->fetch_assoc())
{
$position= $rows['position'];
echo "<option value='$position'>$position</option>";
}
?>
</select>
</br>
<?php echo "Land:" ?>
<?php
$resultSet = $mysqli->query("SELECT land FROM lande");
?>
<select name="land">
<?php
while($rows = $resultSet->fetch_assoc())
{
$land = $rows['land'];
echo "<option value='$land'>$land</option>";
}
?>
</select>
</br>
</br>
<form>
<input class="btn btn-lg btn-success btn-block" type="submit" value="Opret ny spiller" />
</form>
</fieldset>
</form>
</div>
</body>
</html>
<a href="admin.php">Tilbage</a>
<?php } ?>
opretspiller.php:
<?php
include("app.php");
$app = new minAwesomeApp;
?>
<?php
$fuldenavn = ($_POST ['fuldenavn']);
$position = ($_POST ['position']);
$alder = ($_POST ['alder']);
$land = ($_POST ['land']);
$vægt = rand(65, 105);
$højde = rand(160, 205);
$classes = array('Højre','Venstre', 'Begge');
$ben = $classes[array_rand($classes)];
$afslutning = rand(3, 13);
$dribling = rand(3, 13);
$aflevering = rand(3, 13);
$takling = rand(3, 13);
$markering = rand(3, 13);
$straffespark = rand(3, 13);
$mood = rand(3, 13);
$kreativitet = rand(3, 13);
$beslutsomhed = rand(3, 13);
$indflydelse= rand(3, 13);
$kampånd = rand(3, 13);
$udenbold= rand(3, 13);
$acceleration= rand(3, 13);
$balance= rand(3, 13);
$kondition= rand(3, 13);
$hop= rand(3, 13);
$styrke= rand(3, 13);
$udholdenhed= rand(3, 13);
$dato = date("Y/m/d") ;
$transfer = "fri transfer";
$pris= rand(1000, 3000);
$app->DatabaseInsert(
'spillere',
array('fuldenavn','position', 'land', 'alder', 'vægt', 'højde', 'ben', 'afslutning', 'dribling', 'aflevering', 'takling', 'markering', 'straffespark', 'mood', 'kreativitet', 'beslutsomhed', 'indflydelse', 'kampånd', 'udenbold', 'acceleration', 'balance', 'kondition', 'hop', 'styrke', 'udholdenhed', 'oprettelsedato', 'transfer', 'pris'),
array($fuldenavn, $position, $land, $alder, $vægt, $højde, $ben, $afslutning, $dribling, $aflevering, $takling, $markering, $straffespark, $mood, $kreativitet, $beslutsomhed, $indflydelse, $kampånd, $udenbold, $acceleration, $balance, $kondition, $hop, $styrke, $udholdenhed, $dato, $transfer, $pris)
);
?>
<head>
<title>Spillerinfo</title>
<link href="css/opretspiller.css" rel="stylesheet" type="text/css">
<meta charset="utf-8">
</head>
<html>
<body>
<div class="container">
<div class="stats"> <img src="stats1.png"></div>
<div class="fuldenavn"> <p><?php echo $fuldenavn; ?></p></div>
<div class="position"> <p><?php echo $position ; ?></p></div>
<div class="land"> <p><?php echo $land ; ?></p></div>
<div class="højde"> <p><?php echo $højde; echo " cm"; ?></p></div>
<div class="vægt"> <p><?php echo $vægt; echo " kg"; ?></p></div>
<div class="ben"> <p><?php echo $ben; ?></p></div>
<div class="alder"> <p><?php echo $alder; ?></p></div>
<div class="afslutning"> <p><?php echo $afslutning; ?></p></div>
<div class="dribling"> <p><?php echo $dribling; ?></p></div>
<div class="aflevering"> <p><?php echo $aflevering; ?></p></div>
<div class="takling"> <p><?php echo $takling; ?></p></div>
<div class="markering"> <p><?php echo $markering; ?></p></div>
<div class="straffespark"> <p><?php echo $straffespark; ?></p></div>
<div class="mod"> <p><?php echo $mood; ?></p></div>
<div class="kreativitet"> <p><?php echo $kreativitet; ?></p></div>
<div class="beslutsomhed"> <p><?php echo $beslutsomhed; ?></p></div>
<div class="indflydelse"> <p><?php echo $indflydelse; ?></p></div>
<div class="kampånd"> <p><?php echo $kampånd; ?></p></div>
<div class="udenbold"> <p><?php echo $udenbold; ?></p></div>
<div class="acceleration"> <p><?php echo $acceleration; ?></p></div>
<div class="balance"> <p><?php echo $balance; ?></p></div>
<div class="kondition"> <p><?php echo $kondition; ?></p></div>
<div class="hop"> <p><?php echo $hop; ?></p></div>
<div class="styrke"> <p><?php echo $styrke; ?></p></div>
<div class="udholdenhed"> <p><?php echo $udholdenhed; ?></p></div>
<div class="transfer"> <p><?php echo $transfer; ?></p></div>
</div>
</body>
</html>