Instead of $Name use $_POST['Name']
pritaeas
Posting Prodigy
9,310 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86
It will be when you load the page for the first time or even refresh as it's looking for the variable before the page has been submitted to itself.
<form action="form.php" method="post">
If the form is in form.php iteself, then this is a bad idea. Try to use a form handler file to deal with submissions. You then get to stop any resubmissions on page reload.
You could do something like this - have action="form_handler.php" and then in that file have:
<?php
session_start();
if(isset($_SESSION['formMsg']))unset($_SESSION['formMsg']);
if($_POST){
$file = 'form.txt';
$fh = fopen($file, 'w') or die("Can't open file");
if(isset($_POST['Name']))fwrite($fh, $_POST['Name']);
if(isset($_POST['Address']))fwrite($fh, $_POST['Address']);
if(isset($_POST['Email']))fwrite($fh, $_POST['Email']);
fclose($fh);
//the above needs error checking and validation
$_SESSION['formMsg'] = 1;
}else{
$_SESSION['formMsg'] = 2;
}
header("Location: form.php");
?>
diafol
Keep Smiling
10,668 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,514
Skill Endorsements: 57