I keep getting the following error when ever i try using the $POST and $GET variables in php:
Notice: Undefined index: submit in C:\wamp\www\phpexamplepages\ratingsystem\rate.php on line 18
I have tried using the 'isset' function... which does get rid of the error message, but doesn't really fix the problem. I am experiencing this error message in both xammp and wamp.
I don't know what im doing wrong. I have been following a tutorial on youtube and i have produced the exact same code as what is taught in the tutorial and for some reason it just isn't working as it does in the tutorial i have been watching.
Can you help please?
Here is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
//ob_start();
include 'connect.php';
$id = ($_GET['id']);
//process submissionsss
if ($_POST['submit'])
{
// get data
$id_post = $_POST['id'];
$rating_post = $_POST['rating'];
$get = mysql_query("SELECT * FROM animals WHERE id='$id_post'");
$get = mysql_fetch_assoc($get);
$get = $get['rating'];
$newrating = ($get + $rating_post)/2;
$update = mysql_query("UPDATE animals SET rating='$newrating' WHERE id='$id_post'");
header("Location: index.php");
}
?>
<form action="rate.php" method="POST">
choose rating: <br/>
<select name="ratings">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<input type="hidden" name="id" value="<?php echo $id; ?>">
<p/>
<input type="submit" name="submit" value="rate">
</form>
</body>
</html>