Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$_POST[#] doesn't exist ! Why ?! 1

Status
Not open for further replies.

lupidol

Programmer
Apr 23, 2008
125
0
0
IL
Hi everyone,
My php code shows a form where date should be inserted then the date should be assigned to a variable. The trouble is that the value assigned vanishes !!
Here is the code:
Code:
<!doctype html>
<html lang=en>
	<head>
		<title>Show Date</title>
		<meta charset=utf-8>
	</head>
<body>
	<?php
		$dbcon = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) 
				OR die ('Could not connect to MySQL: ' . mysqli_connect_error () ); 
		mysqli_set_charset($dbcon, 'utf8');
		$myDate = trim($_POST['exam_date']);
	?>
	<form action="Day_hours.php" method="post" >
		<input id="exam_date" name="exam_date" type="datetime" />
		<input id="submit"type="submit" name="submit" value="Show Date"/>
	</form>
</body>
And this is the error I recieve:
Notice: Undefined index: exam_date in C:\xampp\htdocs\test\Day_hours.php on line 12
I wish someone would kindly help me with my unseen error.
Thanks
 
there will not be any exam_date key unless the form has been submitted.

you might want to condition it

Code:
if(isset($_POST['submit'])):
  ...
endif;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top