Hi,
I am completely new to PHP and am following this tutorial.
I am 7mins in and my code is exactly identical to his, yet I get an undefined index error. I am using PHP storm
//The form
<html>
<body>
<form action="learnphp.php" method="post">
<table border ="0">
<tr>
<td>Name</td>
<td align="center"><input type ="text" name ="username" size="30"/></td>
</tr>
<tr>
<td>Address</td>
<td align="center"><input type = "text" name ="streetaddress" size = "30"/></td>
</tr>
<tr>
<td>City</td>
<td align = "center"><input type = "text" name ="cityaddress" size = "30"/></td>
</tr>
<tr>
<td colspan="2" align ="center"><input type ="submit" value ="submit"/></td>
</tr>
</table>
</form>
</body>
</html>
//The php code
<!--
You embed PHP code between tags
A semicolon has to finish every php statement
Single quotes : Print what is between them and ignore
escape sequences except for \' and \\
Double quotes : Print many escape sequences, the values
for variables, and more
-->
<html>
<head>
<title>Information Gathered</title>
</head>
<body>
<?php
echo"<p>Data Processed at </p>";
date_default_timezone_set('UTC');
/* Echos the date
h : 12 hr format
H : 24 hr format
i : Minutes
s : Seconds
u : Microseconds
a : Lowercase am or pm
l : Full text for the day
F : Full text for the month
j : Day of the month
S : Suffix for the day st, nd, rd, etc.
Y : 4 digit year
*/
echo date('j F Y H:i');
echo "</p>";
$userName = $_POST['username'];
$streetAddress = $_POST['streetaddress'];
$cityAddress = $_POST['cityaddress'];
echo $userName . "</br>";
echo $streetAddress . "</br>";
echo $cityAddress . "</br>";
?>
</body>
</html>
Notice: Undefined index: username in J:\Private work\web\learnphp.php on line 40
Notice: Undefined index: streetaddress in J:\Private work\web\learnphp.php on line 41
Notice: Undefined index: cityaddress in J:\Private work\web\learnphp.php on line 42
I am thinking that the php code can’t see the form? But they are both in the same folder. Please help so I can continue with the tutorial