Error 403
Posted: 23. April 2013 22:23
Hi!
I know there is alot of topics about this but I can't seem to get any of them working. I am doing some php and MySQL in school right now and I am "haunted" by this 403 error. I've tried the various solutions to this problem but not a single one of them wants to work so therefore I will now ask you in person. I can access the normal start page and all that but the problems begin when trying to edit my MySQL database, the first is to add a car to a table so that you can add them when needed in the database the source code for that is the following:
(sorry for the comments being in Swedish but it's meant for my teacher to see that I know what I'm doing)
This works on my school laptop after small modifications of the httpd-xampp.conf file but with the same modifications to the file on my desktop results in a 403 error when sending the request to add the new car.
Now the other one works almost the same but it prints the table and removes a car instead it looks like this:
So first of all this doesn't work on either of the computers, my conclusion from this is that for some reason it requires you to have different levels of access to do these commands and that the problem and the solution probably lies in the httpd-xampp.conf file but I just can't see it.
If you need any more information just say it and I will provide it.
I know there is alot of topics about this but I can't seem to get any of them working. I am doing some php and MySQL in school right now and I am "haunted" by this 403 error. I've tried the various solutions to this problem but not a single one of them wants to work so therefore I will now ask you in person. I can access the normal start page and all that but the problems begin when trying to edit my MySQL database, the first is to add a car to a table so that you can add them when needed in the database the source code for that is the following:
- Code: Select all
<?php
$host="localhost"; //Den server som kör MySQL
$user="root"; //Ditt användarnamn
$pass=""; //Ditt lösenord
?>
<!-- Vi börjar med ett HTML-formulär för att kunna mata in data -->
<form action="<?echo $_SERVER['PHP_SELF']?>" method="POST">
Registreringsnummer:<br>
<input type="text" name="reg"><p>
Bilmärke:<br>
<input type="text" name="marke"><p>
Modell:<br>
<input type="text" name="modell"><p>
Årsmodell:<br>
<input type="text" name="arsmodell"><p>
Pris:<br>
<input type="text" name="pris"><p>
<input type="submit">
</form>
<?php
//
// Spara undan variablerna från $_POST (som är den
// metod vi använder i formuläret). Se dokumentation
// till PHP för mer information.
//
$reg = $_POST['reg'];
$marke = $_POST['marke'];
$modell = $_POST['modell'];
$arsmodell = $_POST['arsmodell'];
$pris = $_POST['pris'];
//
// Anslut till databasen
//
$conn = mysql_connect( $host, $user, $pass );
if (! $conn) {
print ("Anslutningen misslyckades");
exit;
}
//
// Välj vilken databas du skall använda
//
mysql_select_db("testing");
//
// Kör SQL-frågan, vi bryr oss inte om resultatet
//
mysql_query("INSERT INTO
bilar (reg,marke,modell,arsmodell,pris)
VALUES
('$reg','$marke','$modell','$arsmodell','$pris')");
// Stäng kopplingen till databasen
mysql_close( $conn );
?>
(sorry for the comments being in Swedish but it's meant for my teacher to see that I know what I'm doing)
This works on my school laptop after small modifications of the httpd-xampp.conf file but with the same modifications to the file on my desktop results in a 403 error when sending the request to add the new car.
Now the other one works almost the same but it prints the table and removes a car instead it looks like this:
- Code: Select all
<?php
$host="localhost"; //Den server som kör MySQL
$user="root"; //Ditt användarnamn
$pass=""; //Ditt lösenord
//
// Anslut till databasen
//
$conn = mysql_connect( $host, $user, $pass );
if (! $conn) {
print ("Anslutningen misslyckades");
exit;
}
//
// Välj vilken databas du skall använda
//
mysql_select_db("testing");
//
// Ifall vi fått ett registreringsnummer i $_POST['reg'] från
// formuläret nedan så tar vi bort den bilen nu.
//
if (isset($_POST['reg'])) {
$reg = $_POST['reg'];
$query = mysql_query("DELETE FROM bilar WHERE reg='$reg'");
}
//
// Visa en lista på de bilar som finns i databasen
//
$query = mysql_query("SELECT *FROM bilar");
// Här börjar vi en html-tabell
print ("<table border=\"1\">\n");
//
// Skriv ut de bilar som finns kvar
//
while($t = mysql_fetch_row($query))
{
// Skapa en rad i tabellen med posten
echo "<tr>";
echo "<td>$t[0]</td><td>$t[1]</td><td>$t[2]</td><td>$t[3]</td><td>$t[4]</td>";
echo "</tr>";
}
// Stäng tabellen
print ("</table>");
// Stäng kopplingen till databasen
mysql_close( $conn );
?>
<form action="<?echo $_SERVER['PHP_SELF'];?>" method="POST">
Ange registreringsnummer att ta bort:<br>
<input type="text" name="reg">
<input type="submit">
</form>
So first of all this doesn't work on either of the computers, my conclusion from this is that for some reason it requires you to have different levels of access to do these commands and that the problem and the solution probably lies in the httpd-xampp.conf file but I just can't see it.
If you need any more information just say it and I will provide it.