LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-18-2008, 02:00 AM   #1
konqi
Member
 
Registered: Oct 2007
Distribution: Gentoo, Slackware
Posts: 162

Rep: Reputation: 16
PHP: code says POST, but uses GET


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">&lt;Nieuwe pagina&gt;</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.

Last edited by konqi; 05-18-2008 at 02:04 AM.
 
Old 05-18-2008, 02:18 AM   #2
drauk
Member
 
Registered: Sep 2007
Location: /MX/BC/TJ
Distribution: Slackware 13
Posts: 37

Rep: Reputation: 15
doesn't suppose the first line is method instead methode?
 
Old 05-18-2008, 03:00 AM   #3
konqi
Member
 
Registered: Oct 2007
Distribution: Gentoo, Slackware
Posts: 162

Original Poster
Rep: Reputation: 16
That was the problem, it works now, thanks! It was just a typo.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfixadmin PHP setup file - only displays PHP code davidmbecker Linux - Software 3 04-17-2008 10:33 AM
POST data to PHP code ckoniecny Programming 6 03-02-2006 10:48 PM
merge ASP code with PHP code.. possible ?? ALInux Programming 7 12-30-2005 08:40 AM
I can't post my code yet _Lippy_ Linux - Games 1 12-18-2005 08:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration