Reputation: 429
I have a problem with this code:
<?php echo "<meta http-equiv='refresh' content='3;search_enroll.php?&id='.$id />"; ?>
I'm using this code to pass a value from this page to this page with $id
and it is not empty I echoed $id
and it holds the value. And this is the code on the receiving end:
<?php
if (isset($_POST['SearchS'])){
$id = $_POST['searchstudent'];
}else if(!empty($_GET['id'])){
$id = $_GET['id'];
}
else if(!empty($_GET['student_id'])){
$id = $_GET['student_id'];
}
else {
$id= $_REQUEST['student_id']; <--- this is line 37
}
?>
currently having this error note and I expect the 2nd else
statement should retrieve the code.
Notice: Undefined index: student_id in C:\xampp\htdocs\Thesis\search_enroll.php on line 37
Upvotes: 0
Views: 108
Reputation: 121
This error appears because of your PHP error reporting settings.
Usually, it appears when your variable is not properly set.
Check if $_POST['action']
is set before using it.
Upvotes: 0
Reputation: 14237
You should do:
else {
if(isset($_REQUEST['student_id'])){
$id= $_REQUEST['student_id'];
}
}
This will make sure the student_id
key exists in $_REQUEST
before you try to access it.
Without a check, it will throw the Notice
Upvotes: 0
Reputation: 1
Use the @
suppressor in front of a variable when Undefined index
error occur.
This error occur when variable is not declared first and we used in code:
For eg.
else {
@$id= @$_REQUEST['student_id']; <--- this is line 37
}
But in your case there this else condition should not be run .
Upvotes: 0
Reputation: 846
The meta is not used like that. You hate to specify the URL on a URL subattribute and not just on the CONTENT attribute like that
<META HTTP-EQUIV="Refresh" CONTENT="n; URL=MyURL">
http://en.wikipedia.org/wiki/Meta_refresh
there, your param is never setted
Upvotes: 0
Reputation: 17831
Do your string escaping right or don't do it at all:
<?php
echo "<meta http-equiv='refresh'
content='3;search_enroll.php?id=".$id."' />"; ?>
Upvotes: 2