Im Trying to build a Website that allows people to look for announcements and earn points for actions. However, I cant adjust these points through the form I built. Can anyone Please help?
<?php
ob_start();
require('extra/header.php');
if(empty($_GET['id']))
{
header("Location: index.php");
exit;
}
if($_SESSION['adminlevel'] == 0)
{
header("Location: dashboard.php");
exit;
}
if(empty($_GET['id']))
{
header("Location: index.php");
exit;
}
$userid = $_GET['id'];
$userid = intval($userid);
if(!is_numeric($userid))
{
header("Location: index.php");
exit;
}
if(isset($_POST['Submit'])){//if the submit button is clicked
$points = $_POST['points'];
}
$submitted_username = '';
$query = "
SELECT
username,
email,
verified,
admin,
vtcstaff,
streamer,
mediateam,
suspended,
regdate
FROM users
WHERE
id = :id
";
$query_params = array(
':id' => $userid
);
$query1 = "
INSERT INTO users (
points
) VALUES (
:points
)
WHERE
id = :id
";
$query_params1 = array(
':id' => $userid,
':points' => $_POST['points'],
);
try
{
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch(PDOException $ex)
{
die("Failed to run query: " . $ex->getMessage());
}
$row = $stmt->fetch();
if($row['verified'] == 0 && $row['suspended'] == 0)
{
$verified = "<span class=\\"label label-warning\\">Not Verified</span>";
}
else if($row['verified'] == 0 && $row['suspended'] == 1)
{
$verified = "<span class=\\"label label-danger\\">Suspended User</span>";
}
else if($row['verified'] == 1 && $row['suspended'] == 0)
{
$verified = "<span class=\\"label label-success\\">Verified User</span>";
}
else if($row['verified'] == 1 && $row['suspended'] == 1)
{
$verified = "<span class=\\"label label-danger\\">Suspended User</span>";
}
if($row['vtcstaff'] == 1)
{
$vtcstaff = "<span class=\\"label label-success\\">VTC Staff</span>";
}
if($row['streamer'] == 1)
{
$streamer = "<span class=\\"label label-success\\">Official Twitch Streamer</span>";
}
if($row['mediateam'] == 1)
{
$media = "<span class=\\"label label-success\\">Media Team</span>";
}
if($row)
{
$regdate = htmlentities($row['regdate'], ENT_QUOTES, 'UTF-8');
$regdate = strtotime($regdate);
?>
<div class="container">
<center>
<h3>User Information</h3>
<div class="well well-sm" style="width: 500px;"><a href="verify.php?id=<?php echo $_GET['id']; ?>">VERIFY</a> - <a href="suspend.php?id=<?php echo $_GET['id']; ?>">SUSPEND</a> - <a href="media.php?id=<?php echo $_GET['id']; ?>">Add to Media Team</a></div>
<div class="well well-sm" style="width: 500px;"><b>Username: </b> <?php echo stripslashes(htmlentities($row['username'], ENT_QUOTES, 'UTF-8')); ?></div>
<div class="well well-sm" style="width: 500px;"><b>Status: </b> <?php echo $verified; echo $vtcstaff; ?><?php echo $streamer; echo $media ?></div>
<div class="well well-sm" style="width: 500px;"><b>Registration Date: </b> <?php echo date("m-d-Y", $regdate); ?> </div>
<br />
<?php
$query = "
SELECT
*
FROM drive_routes
WHERE status = 2 AND driver = ". $_GET['id'] ."
";
try
{
$stmt = $db->prepare($query);
$result = $stmt->execute();
}
catch(PDOException $ex)
{
die("Failed to run query: " . $ex->getMessage());
}
$countroutes = $stmt->rowCount();
$query1 = "
SELECT
*
FROM drive_routes
WHERE status = 2 AND driver = ". $_GET['id'] ."
";
try
{
$stmt2 = $db->prepare($query1);
$result = $stmt2->execute();
}
catch(PDOException $ex)
{
die("Failed to run query: " . $ex->getMessage());
}
$rows2 = $stmt2->fetchAll();
$totalmoney = 0;
$total = 0;
foreach($rows2 as $row){
$total = $total + $row['distance'];
$totalmoney = $totalmoney + ($row['price'] - $row['costs']);
}
?>
<h3>Driving Information</h3>
<div class="well well-sm" style="width: 500px;">
<b>Total Accepted Deliveries: </b> <?php echo $countroutes; ?></br>
<b>Total Miles Driven: </b> <?php echo $total; ?></br>
<b>Total Money Earned: </b> £<?php echo $totalmoney; ?></br>
</div>
<h3> Add Points
<div class="well well-sm" style="width: 500px;">
<form class="form-signin" role="form" action="editprofile.php" method="post">
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
<input type="number" name="points" class="form-control" placeholder="points" required><br />
<button class="btn btn-lg btn-primary btn-block" type="submit">Confirm</button>
</form>
</div>
</center>
</div>
<?php require('extra/footer.php'); ?>
<?php
}
else
{
echo"<div class= \\"container \\">";
echo" <br />";
echo" <h2>Error!</h2>";
echo" <p>This profile doesn't exist, try another!</p>";
echo"</div>";
require('extra/footer.php');
}
?>
Thanks For Any Help!