i am getting this error

Notice: Undefined index: firstName in C:\xampp\htdocs\flasblog\test.php on line 3

Notice: Undefined index: lastName in C:\xampp\htdocs\flasblog\test.php on line 3

here is my php code

<?php include_once"scripts/connect.php"; ?>
<?php
$text=$_POST['firstName']." ".$_POST['lastName'];
$to="anubhavjhalani09@gmail.com";
$subject="Message from php";



//data insert into database
$sql="INSERT INTO entries (contents)
VALUES
('$text')";

echo $text;
?>

please somebody help me !!!!!!!!! i know how to hide this error but its not the solution of this problem.i am getting the variables from a flash file which is in the same folder.

Add this to the start of your code:

echo "Post:".print_r($_POST,true);
echo "Get: ".print_r($_GET,true);

This should give you an idea of what Flash is passing to your script.

thanx for the reply
now i am getting this


Post:Array ( ) Get: Array ( )
Notice: Undefined index: firstName in C:\xampp\htdocs\flasblog\test.php on line 5

Notice: Undefined index: lastName in C:\xampp\htdocs\flasblog\test.php on line 5

my php script is

<?php include_once"scripts/connect.php"; ?>
<?php
    echo "Post:".print_r($_POST,true);
    echo "Get: ".print_r($_GET,true);
$text=$_POST['firstName']." ".$_POST['lastName'];
$to="anubhavjhalani09@gmail.com";
$subject="Message from php";



//data insert into database
$sql="INSERT INTO entries (contents)
VALUES
('$text')";

echo $text;
?>

now what does it mean ??

Is this happening AFTER you submit the Flash form? If you were to call test.php directly you would expect to get those warnings since nothing was passed to it via get or post.

If so, it doesn't look like the flash form is passing anything to test.php on submit.

Try this:

if(isset($_POST['firstName'] && $_POST['lastName'])) {
$text=$_POST['firstName']." ".$_POST['lastName'];
$to="anubhavjhalani09@gmail.com";
$subject="Message from php";



//data insert into database
$sql="INSERT INTO entries (contents)
VALUES
('$text')";

echo $text;
}

heyy i just play my flash movie and then i check the test.php page on browser and then i am getting this error .is this the right way to send variables to php by just playing the flash movie?????my fla , swf and php file is in the same folder

@zero13
i tried your code . now i m getting this error

Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in C:\xampp\htdocs\flasblog\test.php on line 3

my php code is

<?php include_once"scripts/connect.php"; ?>
<?php
        if(isset($_POST['firstName'] && $_POST['lastName'])) {
    $text=$_POST['firstName']." ".$_POST['lastName'];
    $to="anubhavjhalani09@gmail.com";
    $subject="Message from php";
     
     
     
    //data insert into database
    $sql="INSERT INTO entries (contents)
    VALUES
    ('$text')";
     
    echo $text;
    }
?>

now what to do ??? and also look at my question above

heyy i just play my flash movie and then i check the test.php page on browser and then i am getting this error .is this the right way to send variables to php by just playing the flash movie?????my fla , swf and php file is in the same folder

No. You don't play a flash movie and then visit another page. A form, be it from html or flash, must be submitted and pass information to a script. The POST is passed within the request the browser makes to the web server when calling the form handler.

No. You don't play a flash movie and then visit another page. A form, be it from html or flash, must be submitted and pass information to a script. The POST is passed within the request the browser makes to the web server when calling the form handler.

please write your answer in simple english . i am not a native english speaker

@zero13
i tried your code . now i m getting this error

Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in C:\xampp\htdocs\flasblog\test.php on line 3

my php code is

<?php include_once"scripts/connect.php"; ?>
<?php
        if(isset($_POST['firstName'] && $_POST['lastName'])) {
    $text=$_POST['firstName']." ".$_POST['lastName'];
    $to="anubhavjhalani09@gmail.com";
    $subject="Message from php";
     
     
     
    //data insert into database
    $sql="INSERT INTO entries (contents)
    VALUES
    ('$text')";
     
    echo $text;
    }
?>

now what to do ??? and also look at my question above

<?php
include_once"scripts/connect.php";
if(isset($_POST['firstName']) && isset($_POST['lastName'])) {
    $text=$_POST['firstName']." ".$_POST['lastName'];
    $text = str_replace("'",'& # 3 9 ;',$text);//ascii code for a quote
    $to="anubhavjhalani09@gmail.com";
    $subject="Message from php";
         
    //data insert into database
    $sql="INSERT INTO entries (contents) VALUES ('$text')";
     
    echo $text;
}else{
    echo 'not set';
}
?>

heyy i just play my flash movie and then i check the test.php page on browser and then i am getting this error .is this the right way to send variables to php by just playing the flash movie?????my fla , swf and php file is in the same folder

Yeah, when you submit a form it sends the contents you type in via POST variables, your form is expecting them to run (isset($_POST)) without them (navigating to it in a browser) it doesn't have the data so should just ignore the request eg. echo 'not set';

the undefined index notice is just telling you them post variables are not there, isset checks if they are first so it doesn't give a notice and you can tell it to do something else if they arn't

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.