There is an html page:
<html> <head> <title> </title> </head> <body> <form action="processorder.php" method = "post"> <table border = "0"> <tr bgcolor ="#cccccc"> <td width="150">Product</td> <td width= "15">Quantity</td> </tr> <tr> <td>Tyres</td> <td align="center"><input type="text" name="tireqty" size="3" maxlength="3"></td> </tr> </tr> <td>Oil</td> <td align="center"><input type="text" name="oilqty" size="3" maxlength="3"></td> </tr> <tr> <td>spark plug</td> <td align="center"><input type="text" name="sparkqty" size="3" maxlength="3"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="send order"/></td> </tr> </table> </form> </body> </html> Php file goes to it
<html> <head> <title> Order result </title> </head> <body> <h1>auto parts</h1> <h2>order results</h2> <?php $tireqty=$_POST['tireqty']; $oilqty=$_POST['oilqty']; $sparkqty=$_POST['sparkqty']; echo "<p> order is processed at "; echo date('H:i, jS F Y'); echo '</p>'; echo '<p> Ordered: </p>'; echo $tireqty.' tires <br/>'; echo $oilqty.' oil bottles <br/>'; echo $sparkqty.' spark plugs <br/>'; ?> ?> </body> </html> When starting from a hosting, everything works, locally it gives an error:
Notice: Undefined offset: 1 in D: \ PHP \ second \ processorder.php on line 12
Notice: Undefined offset: 2 in D: \ PHP \ second \ processorder.php on line 13
Notice: Undefined offset: 3 in D: \ PHP \ second \ processorder.php on line 14
Actually, he sees a mistake here:
$tireqty=$_POST['tireqty']; $oilqty=$_POST['oilqty']; $sparkqty=$_POST['sparkqty']; IDE - PhpStorm 2016.1 Web Server - XAMP
$_POST['tireqty'], that’s not what is highlighted ... but this is not a mistake in principle, but a notification .... But it says that there is no such variable as$_POST['tireqty'],$_POST['oilqty']and the other from the post .... and all because. that at the time of creating the page they really do not ... and appear only when you send a post request ...... respectively, you need to check for existence ...$tireqty= isset($_POST['tireqty']) ? $_POST['tireqty'] : 'defaultValue'$tireqty= isset($_POST['tireqty']) ? $_POST['tireqty'] : 'defaultValue'and the rest also - Alexey Shimansky