How can i solve it?

This happens when you visit the page or when you submit the form?

If it happens when you visit the page you have to check if is set $_POST['date'], because input field value and name is added to $_POST array AFTER form submition.

The error message is because the $_POST['date'] array variable is not set. Usually it is set from a form.

it is best to test and set a variable rather than assuming the variable exists:

<?php

$_session_start();

$date = isset( $_POST['date'] ) ? $_POST['date'] : NULL;

if( $date ):
	for($i=0; ....) {
		...
	}

else:
	echo 'Yes we have no $_POST["date"]';
endif;

Please note how the above script was formatted by being including between two lines each containing three backticks only.

Supplying script is preferred rather than a screen dump.

This code makes no sense.

Given $_POST[‘date’] is array, why only a last value is stored in the session?
If there are multiple values, then they all should be stored in a session, not only one.
If only one value is needed, then there should be no array.

As of the error, it’s simple. $_POST should be processed only in case there was a POST request. To do so, simply run your code within a condition,

if ($_POST) {

}

Obviously, to get $_POST[‘date’] there should be a form sent wia POST with a field named “date”

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.