If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

My question would be, do you have an input on your form named 'Submit' that has a value in it? Just having a submit button is not the same thing and so when you check $_POST['Submit'] there won't be a value and that entire block will be skipped. A better way to check if a form has been submitted would be to use

PHP Code:

if(isset($_POST)) {
// Do stuff here
}

"Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

I'm not really understanding what you are trying to ask at this point... In your original code you claimed you couldn't access those variables while they were inside of your if statement (if(isset($_POST['Submit'])){}). You don't have a field with a name 'Submit' that will get posted to PHP so I presented the correct way to check if a form had been submitted, which would replace your if(isset($_POST['Submit'])){ line of code.

So based on what you originally stated your code would look like this:

why u are initializing like this?
$name = "";
$email= "";
i am doing
$name = $_POST["name"];
$email = $_POST["email"];
i have some other fields also like age,gender,, its not code duplication.. first time initialize with empty value then put the value in it.. why ????

As much as I'd like to solve your problem, your code really is all over the place. It's hard to tell you what's wrong because I'm not seeing everything, only pieces of your code and frankly they don't seem to be in any order.

For instance, 2 post up (post #7), you mention the error on line 77 and 78. Based on the code you provided in that post it doesn't appear possible that you could get those 2 errors on consecutive lines. In your next post your code seems to have changed, but you have the same error. While you seem to point to the actual lines the error is on, I wonder how much of your code I'm not seeing.

On a separate but related note, generally when setting values from POST variables you should always use some sort of conditional assignment to prevent error from missing/empty values. An example:

PHP Code:

$name = (isset($_POST['name'])) ? $_POST['name'] : "";

This prevents any issue in the event that name is not submitted in the POST. But again, I have no idea if this will help you or not as I honestly have no idea what your code looks like. I just keep getting little snippets that seem to keep changing.

"Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

The 2 errors stated there were undefined indices on 2 lines, however, no where in your code snippets would those errors occur, so we would need to see larger, more complete code snippets.

In regards to checking whether $_POST variables are set, you should always do this but it's up to you and what you want to happen as to whether you want to use a condensed way of checking if the $_POST variable are set or explicitly write if-else blocks.

Mind you, I'm not a big advocate of assigning everything in $_POST to scalar variables, as you are just duplicating what is already in $_POST. E.g., in a simple example:

PHP Code:

// why do this:
$foo = $_POST['foo'];
echo $foo;

// when you could just do this:
echo $_POST['foo'];

Plus, at any point in your code where you use $_POST['foo'], you automatically know it's from posted form data, so you don't have to trace a variable back to its source to find out where/how it was set. If you take that approach, then you would just change the above to: