Marc
Marc

Reputation: 9537

php post variable not recognized

I am facing a very strange behavior with something very basic. At the beginning of my PHP script I am testing if a POST variable called "multiplicateur" is set. I am testing this in my browser by manually entering the url. The response is telling me that the post variable is not set whereas it is set in my url. Hope someone can help. Thank you in advance for your replies. Cheers. Marc.

My url:

myurl/php/calendar.php?multiplicateur=3

My PHP:

<?php
session_start();
header('Content-Type: text/html; charset=utf-8');
require("../inc/connect.inc.php");

if(isset($_POST['multiplicateur'])){
    echo 'multiplicateur set';
}
else{
    echo 'multiplicateur not set';
}
?>

Upvotes: 0

Views: 680

Answers (3)

Gediminas Zutautas
Gediminas Zutautas

Reputation: 16

If you get that variable from 'form' tag, then you need to specify what method you need: 1) method='get' for data to be sent via url, and retrieved with $_GET['name of variable']; 2) method='post' for data to be hidden, and retrieved with $_POST['name of variable'];

Upvotes: 0

Nikson Kanti Paul
Nikson Kanti Paul

Reputation: 3440

use $_GET['multiplicateur']

its posting as get method

Upvotes: 0

Sarfraz
Sarfraz

Reputation: 382696

Use $_GET['multiplicateur'] since your variable comes from URL.

The predefined $_GET variable is used to collect values in a form with method="get"

Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send.


For more info about it, see:

Upvotes: 8

Related Questions