I have a problem with PHP, in a form it says action="post", but when i click the submit button, all the information is send to the url. After that i can only use $_GET to get the data from the url.
Here is the code, this file is included into another file
Code:
<form action="../php/changePage.php" methode="post">
<?php global $date, $time;?>
<fieldset>
<legend>Wijzig een pagina toe</legend>
<table>
<tr>
<td><label for="page">Kies een pagina:</label></td>
<td>
<select name="page" id="page">
<?php $sql = 'SELECT pageName, menuText FROM pages WHERE category="standaard"';
$query = mysql_query($sql) or die(ordie());
while ($pages = mysql_fetch_assoc($query)) {
$pageName = $pages['pageName'];
$menuText = $pages['menuText'];
echo '<option value="'.$pageName.'">'.$menuText.'</option>';
}
echo '<option selected="selected" value="new"><Nieuwe pagina></option>';
?>
</select>
<input type="checkbox" name="rem" id="rem" /><label for="rem">Verwijder</label>
</td>
</tr>
<tr>
<td><label for="title">Titel:</label></td>
<td><input class="text" type="text" name="title" id="title" /></td>
</tr>
<tr>
<td><label for="menuText">Menu tekst:</label></td>
<td><input class="text" type="text" name="menuText" id="menuText" /></td>
</tr>
<tr>
<td><label for="pageName">Pagina naam:</label></td>
<td><input class="text" type="text" name="title" id="title" /></td>
</tr>
<tr>
<td><label for="cat">Categorie</label></td>
<td><select name="cat" id="cat">
<?php $sql = "SELECT DISTINCT category FROM pages WHERE category!='cms'";
$query = mysql_query($sql) or die(ordie());
while ($category = mysql_fetch_assoc($query)) {
$category = $category['category'];
echo '<option value="'.$category.'">'.$category.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td><label for="visible">Zichtbaar in het menu</label></td>
<td><select name="visible" id="visible">
<option value="1">Ja</option>
<option value="0">Nee</option>
</select>
</td>
</tr>
<td><label for="pos">Positie in het menu</label></td>
<td><select name="pos" id="pos">
<?php $sql = "SELECT DISTINCT position FROM pages";
$query = mysql_query($sql) or die(ordie());
while ($pos = mysql_fetch_assoc($query)) {
$pos = $pos['position'];
echo '<option value="'.$pos.'">'.$pos.'</option>';
}
echo $pos;
$pos = $pos+1;
echo '<option value="'.$pos.'">'.$pos.'</option>';
?>
</select>
</td>
<tr>
</table>
<input class="button" type="submit" value="Verzenden" id="submit" name="submit" />
</fieldset>
</form>
And here changePage.php
Code:
<?php if ($_SERVER['HTTP_REFERER'] == 'http://localhost/sites/bt/admin/index.php?pagina=pages') {
$path = '../';
include '../include/framework.php';
// WHEN I CHANGE IT DOWN BELOW TO $_GET THEN IT WORKS
$page = $_POST['page'];
$title = $_POST['title'];
$menuText = $_POST['menuText'];
$pageName = $_POST['pageName'];
$category = $_POST['cat'];
$visible = $_POST['visible'];
$position = $_POST['position'];
if ($page == 'new') {
$sql = "INSERT INTO pages (pageName, title, menuText, category, visible, position) VALUES ('$pageName', '$title', '$menuText', '$category', '$visible', '$position')";
mysql_query($sql) or die(mysql_error());
$message = '<p>De pagina '.$menuText.' is toegevoegd.</p>';
}
else {
if ($rem == '1') {
$sql = "DELETE FROM pages WHERE pageName='$page'";
mysql_query($sql) or die(mysql_error());
$message = '<p>De pagina is verwijderd.</p>';
}
else {
$sql = "UPDATE pages SET pageName='$pageName', title='$title', menuText='$menuText', visible='$visible', position='$position' WHERE pageName='$page'";
mysql_query($sql) or die(mysql_error());
$message = '<p>De pagina is nu aangepast</p>';
}
}
echo $message;
}
else {
echo '<p>Roep het script aan vanaf de goede pagina.</p>';
}
?>
I think there is a problem with the page with the form on it, but i don't know what.