Pikk
Pikk

Reputation: 2743

How to change form from get to post?

the links of this form have question marks:

This is a file: sidebar.php

echo
<form method='get'>
    <div class='left'>
     <div class='btn-group-vertical'> 
             <!-- Vertically Stck button group -->
       <button 'submit' name='Service)name' class='btn btn-default'>Service Name</button>
       <button type='submit' name='YYY_Service' class='btn btn-default'>YYY Service</button>

      </div>
      </form>; 
      ?>

This is a part of index.php:

ini_set('session.save_path','/path/to/session');
session_start();
error_reporting(E_ALL); ini_set('display_errors', 1);

$current_menu='empty.php'; //If no menu/button is selected get right column empty(empty.php)


if(isset($_REQUEST['Service'])){$current_menu='serviceform.php';}
if(isset($_REQUEST['YYY_Service'])){$current_menu='yyyform.php';}

This is showing URLS such as:

www.foo.com/index.php?Service=
www.foo.com/index.php?YYY_Service=

How should this form changed in order to show instead urls this way?

www.foo.com/serviceform.php
www.foo.com/yyyform.php

And this code in another file:

function Button_set($name, $newline)
{

   if($newline){
   ?>
    <br><br><input type="button" name="<?=$name?>" value="<?=$name?>" /input>
   <?php
   }
   else if (!$newline){
   ?>
    <input type="button" name="<?=$name?>" value="<?=$name?>" /input>
   <?php
   }

 }  

If I only change the form method to POST it doesn't work...

Upvotes: 1

Views: 1960

Answers (1)

MaciekGrynda
MaciekGrynda

Reputation: 703

Change:

<form method="get">

to:

<form method="post">

Also add attribute "action" to site you want:

<form method="post" action="serviceform.php">

<form method="post" action="yyyform.php">

W3C link on form

Upvotes: 3

Related Questions