T.W.I.M.C,
Plese, Acess the code Below:
File Name = C:\Dev\php\practice.php
code:
<html>
<head>
<title>PHP Practice::I Am Getting Bata!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h3>Testing things stored in Session
<form action="practice.php" method="post" name="testForm">
UserName<input name="name" type="text"><br>
Password<input name="pword" type="password">
<br>
<input name="submit" type="submit" value="Submit">
</form>
<?php
if($_POST['submit']){
$name = $_POST['name'];
$password = $_POST['pword'];
}
print"$name<br>";
print"$password";
?>
</h3>
</body>
</html>
What I intended to do with this code was to collect the values on the form fields and print it right under the form on the same page.. only when the submit button is clicked. my litle code works fine.. but when ever i load the page for the first time, i get the following errors:
Notice: Undefined index: submit in C:\Dev\php\practice.php on line 18
Notice: Undefined variable: name in C:\Dev\php\practice.php on line 22
Notice: Undefined variable: password in C:\Dev\php\practice.php on line 23
..after which when i click the submit button, the error goes and what ever i have in the fields are printed.
I know the reason for the error is because there are no values yet in the submit, name, pword varables. I need to know how I can do such validation without having to see the
quote:
Undefined index
error when i load my page for the first time.
-Fikayo
(Edited by Fikzy on 10-04-2004 18:30)