0

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';
}
?>
2
  • 1
    POST is from a form that has a method of POST using $_POST[], if the form has GET or that you're passing data through a URL then it is $_GET[] Commented Feb 27, 2012 at 12:41
  • 1
    POST arguments are sent in the body of the request, they are not appended to the URL. Commented Feb 27, 2012 at 12:42

3 Answers 3

8

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:

Sign up to request clarification or add additional context in comments.

2 Comments

Oh Ok! So when i use it through an ajax call with the post method then I keep POST, but when I want to test it manually by entering the url I should use GET? Coorect?
@Marc: Yes you are right, you can learn more about it in the link I have provided in my answer :)
0

use $_GET['multiplicateur']

its posting as get method

Comments

0

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'];

1 Comment

hey man this post of yours is really hilarious xD kudos! 38.media.tumblr.com/d8ced832af9e52f7ed9dc65017d0b353/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.