This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 7 years ago.
i have got this code in my connect.php
$firstname=$_POST['firstname'];
$_SESSION['firstname']=$firstname;
And this in my Main.php
$_SESSION['firstname']=$firstname;
echo $firstname;
But it gives me this error Undefined variable: firstname in
In your connect you should have something like
<?php
session_start();
$_SESSION['firstname'] = $_POST['firstname'];
and in Main.php
<?php
session_start();
echo $_SESSION['firstname'];
Related
This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Can I mix MySQL APIs in PHP?
(4 answers)
Closed 5 years ago.
I'm having a problem here
This is my forgot pass.php code
<?php
if(isset($_POST['submit_email']) && $_POST['email'])
{
require 'connect.php';
include 'connect.php';
$select=mysqli_query($con, "SELECT * from `users` where email='$email'");
if(mysqli_num_rows($select)==1)
{
while($row=mysql_fetch_array($select))
{
$email=($row['email']);
$pass=md5($row['password']);
}
I'm getting the error Undefined variable: email on line 6.
Thanks in advance for helping
This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 6 years ago.
What I want to do is echo the value of $test on my page, through the uri. I know I'm doing something wrong, but I can't figure out what.
Code:
<?php echo $test?>
URL:
localhost/testMap/test.php?test=hallo
You can get the value of url with a get, and store it in the variable $test and then echo that out.
$test = $_GET['test'];
This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 6 years ago.
please could you help me to show the username on the page?
I got this error:
Notice: Undefined index:
<?= $_SESSION['auth']->pseudo; ?>
This is the begining
<?php
session_start();
//require 'functions.php';
$title = "Accueil | Wintrack";
require 'include/header.php';
require 'dbconnection.php';
logged_only();
This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 7 years ago.
here is my php. the session ps comes from a another php page. it comes successfully. but i am getting undefined when i try to use it on the following code to connect to my db.
<?php
$pss = "";
session_start();
if(isset($_SESSION['ps'])){
$pss = $_SESSION['ps'];
}
echo $pss;
$connect = mysqli_connect("localhost","root","","erthiph_asksheikh851821217");
mysqli_query($connect,"INSERT INTO `as_questions`(`Qid`, `M_class`, `S_class`, `Question`, `Answer`, `Doctor`, `Time`) VALUES
('','','','".$pss."','','',CURRENT_TIMESTAMP)");
?>
the above code works. i replaced '$_POST[postquestion]' with '".#pss."'
please check edit history to check edits.
change '$_POST[$pss]' to '".$pss."'
This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 8 years ago.
Im getting the following error: Notice:undefined index:done
please advise what is wrong
<?php
if($_Get['done']==1 $msg = "Account details saved";
?>
Check first if the key exists, then the comparison to 1.
if (isset($_GET['done']) && $_GET['done'] == 1) {
$msg = '...';
}