Request Detail for single request

Date this request was submitted: 2022-05-23 16:40:29 (4 months ago)

Posted by: 2223_b2_rr

Course: Designing Solutions Through Programming (Block 1, Room C152)

Date this request was closed: 2022-06-09 13:24:17 (3 months ago)

Status: closed

Priority: Average


Original request for help:

 

Hi. So I'm working on adding a function where a user can recommend sources to study from. And for that, I have created an add function with a type of forum where a user can input data. Then I made a process page and lastly the view all the recommended sources page. But the issue is that it doesn't want to show the data nor add it to the database (it is not showing on phpMyAdmin). I checked that all the variables are the same, the database name is correct and I have used a code from before that worked, which we did at the beginning of the school year. My question is if you can spot a mistake in the code since I cannot? The issue is with the last piece of code I belive but inserted all of it just in case

Thank you

forum:

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
        <title>Welcome to IBDP site recomendation</title>
        <h4>If any inapropiate or neagtive site will be recommended this funtion on the website will be deleted!</h4>
    </head>
    <body>
        <?php include('resource_navbar.php'); ?>
        <div class="container mt-5">
        <form action ="resource_add_process.php" method="POST">
        <div class=" mb-2">
            <label for="name">Name</label>
            <input name="description" type="text" class="form-control" id="name"  placeholder="Enter name">
        </div>
        <div class=" mb-2">
            <label for="link">Link</label>
            <input name="link" type="text" class="form-control" id="link"  placeholder="Enter link/url">
        </div>
        <div class=" mb-2">
            <label for="description">Description</label>
            <input name="description" type="text" class="form-control" id="description"  placeholder="Enter description">
        </div>
        <div class=" mb-2">
            <label for="level">Level</label>
            <input name="level" type="text" class="form-control" id="level"  placeholder="Enter level: HL/SL">
        </div>
        
        <button type="submit" class="btn btn-primary mt-4">Add a new item</button>
        </form>
        </div> <!-- closing container div --> 
        <?php 
        include('rescource_footer.php');
        ?>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ" crossorigin="anonymous"></script>
    </body>
</html>

process:

<?php 
// This file should be named store_add_new_item_process.php 

include('recomendsou_inc.php');

$name = $_POST['name'];
$link = $_POST['link'];
$description = $_POST['description'];
$subject = $_POST['subject'];
$level = $_POST['level'];

$result = mysqli_query($connect,
    "INSERT INTO `items` 
    (`qname`, `link`, `description`, `subject`, `level`) 
    VALUES ('$name', '$link', '$description','$subject','$level');");


header('location:reccomend_resource_view.php');
?>

Show:

<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
        <title>Resources for the IB DP subcjects</title>
    </head>
    <body>
<?php 
include('resource_navbar.php'); 
include('recomendsou_inc.php');
$row_counter = 0;
?>

<div class="row">
    <div class="col-12 text-center">
      <h2>Recomended Resources by other Users</h2>
    </div>
  </div>






  <div class="row mt-4">
<?php

$query_all_items = mysqli_query($connect, "SELECT * FROM recomendsou;");
while ($row = mysqli_fetch_array($query_all_items))
{
?>


#personal note: use same variables for the products table and use the variables to get the products. It will be easier. Delete array column in skincare routines?

 <!-- Start row 1 -->
  <div class="col-4">
            <div class="card">
                <div class="card-body">
                    <p class="card-text"><?php echo $row['name']; ?></p>
                    <p class="card-text"><?php echo $row['subject']; ?></p>
                    <p class="card-text"><?php echo $row['level']; ?>"> </p>
                    <p href="<?php echo $row['link']; ?>"> link </p>
                </div>
            </div>
        </div>

    <?php 
        $row_counter = $row_counter +1; 
        if ($row_counter == 3) {
            echo "</div>";
            echo "<div class=\"row mt-3\">";
            $row_counter = 0;
        }
    
    ?>  
          
    </div> <!-- closing container div --> 

<?php 
    include('resource_footer.php');
?>
<!-- please don't touch anything below this line --> 
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ" crossorigin="anonymous"></script>
</body>
</html>

 


Login to reply

If you were logged in you could reply!