skip to Main Content

Hello!
this is schoolwork, so it is probaly a very simple mistake. as i am a beginner, with basic knowledge i would really apreciate getting a straightfoward and easy answer:) thanks in advance!

the Document i started with

<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>

<?php

$tjener = "localhost";
$brukernavn = "root";
$passord= "";
$database= "testfjell";

$kobling = new mysqli($tjener, $brukernavn, $passord, $database);

if ($kobling-> connect_error) {
  die("noe gikk galt med koblingen ". connect_error);
  // code...
}
else {
//  echo "koblingen kjører!";
}
$kobling->set_charset("utf8");

$sql= "SELECT * FROM fjell";
$resultat = $kobling->query($sql);

echo "<form method='post' action='endretilfjelltest.php>'";
while ($rad=$resultat-> fetch_assoc()) {
$fjell_id = $rad["fjell_id"];
$fjell= $rad["fjell"];
echo "<br>";
echo "  $fjell ";

echo "<input type= 'hidden' name= 'endre_id value='$fjell_id'>";
echo "<input type= 'submit' name='endre' value= 'endre'";

}
echo "</form>";
 ?>


  </body>
</html>

the document i thought were going to appear

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>

<?php
if(isset($_POST["endre_id"])){
  $endre_id=$_POST["endre_id"]

$tjener = "localhost";
$brukernavn = "root";
$passord= " ";
$database= "testfjell";

$kobling = new mysqli($tjener, $brukernavn, $passord, $database);

if ($kobling-> connect_error) {
  die("noe gikk galt med koblingen ". connect_error);
  // code...
}
$kobling->set_charset("utf8");

}
else {
  die("du må angi et fjell")
}

$sql= "SELECT * FROM fjell WHERE fjell_id = '$endre_id'";
$resultat= $kobling->query($sql);

echo "<form action= 'endre3fjell.php' method='POST'";
while($rad=$resultat->fetch_assoc()){
  $fjell_id=$rad["fjell_id"];
  $fjell=$rad["fjell"];

  echo "ID";
  echo "<input type='number' name='fjell_id' value = '$fjell_id' disabled>";
  echo "FJELL";
  echo "<input type= 'text' name='nyttfjell' value= '$fjell'>";
}

echo "<input type= 'submit' name='endre' value='endre>'"
echo "</form>";

 ?>


  </body>
</html>

the message i got i google chrome :

Forbidden
You don’t have permission to access /endretilfjelltest.php> on this server.
Apache/2.4.9 (Win64) PHP/5.5.12 Server at 127.0.0.1 Port 80

i do not have a teacher, and are trying to understand it by myself. I woul really apreciate if you would take a moment to help me out!
thanks again:)

2

Answers


  1. Chosen as BEST ANSWER

    Thank You! I figured it out, i had simply written

    echo "<form method='post' action='endretilfjelltest.php>'"; 
    

    instead of

    echo "<form method='post' action='endretilfjelltest.php'>";


  2. The error message has nothing to do with PHP. Your webserver (Apache) is telling you that
    either the user account under which the server is running does not have access to the file “endretilfjelltest.php” or the file “endretilfjelltest.php” does not exist.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search