guyfromfl Posted March 22, 2007 Share Posted March 22, 2007 Ok this is driving me nuts. my httpd error_log keeps saying undefined index for each of the vars passed every time i try to submit. I can't find a syntax error in the code tho. newBand.php <html> <body> <form action="addBand.php" method="POST" name="newBand"> Band Name: <input type="text" align="RIGHT" name="bandName" id="bandName"><br> Style:<input type="text" align="right" name="style" id="style"><br> Website:<input type="text" name="website" id="website"><br> Myspace:<input type="text" name="myspace" id="website"><br> Label: <input type="text" name="label" id="label"><br> Members:<input type="text" name="mem1" id="mem1"><input type="text" name="mem1pos" is="mem1"><br> <input type="text" name="mem2" id="mem2"><input type="text" name="mem2pos" id="mem2pos"><br> <input type="text" name="mem3" id="mem3"><input type="text" name="mem3pos" id="mem3pos"><br> <input type="text" name="mem4" id="mem4"><input type="text" name="mem4pos" id="mem4pos"><br> <input type="text" name="mem5" id="mem5"><input type="text" name="mem5pos" id="mem5pos"><br> <input type="text" name="mem6" id="mem6"><input type="text" name="mem6pos" id="mem6pos"><br> <input type="text" name="mem7" id="mem7"><input type="text" name="mem7pos" id="mem7pos"><br> <input type="text" name="mem8" id="mem8"><input type="text" name="mem8pos" id="mem8pos"><br> <input type="text" name="mem9" id="mem9"><input type="text" name="mem9pos" id="mem9pos"><br> <input type="text" name="mem0" is="mem0"><input type="text" name="mem0pos" id="mem0pos"><br> Description:<textarea cols="100" rows="6" wrap="VIRTUAL" name="description" id="description"></textarea><br> Hometown: <input type="text" name="hometown" id="hometown"><br> <input type="submit" name="submit" Value="Add Band"> </form> </body> </html> And the file it passes _POST to (addBand.php) <?php $bandName = $_POST['bandName']; $style = $_POST['style']; $website = $_POST['website']; $myspace = $_POST['myspace']; $label = $_POST['label']; $mem1 = $_POST['mem1']; $mem1pos = $_POST['mem1pos']; $mem2 = $_POST['mem2']; $mem2pos = $_POST['mem2pos']; $mem3 = $_POST['mem3']; $mem3pos = $_POST['mem3pos']; $mem4 = $_POST['mem4']; $mem4pos = $_POST['mem4pos']; $mem5 = $_POST['mem5']; $mem5pos = $_POST['mem5pos']; $mem6 = $_POST['mem6']; $mem6pos = $_POST['mem6pos']; $mem7 = $_POST['mem7']; $mem7pos = $_POST['mem7pos']; $mem8 = $_POST['mem8']; $mem8pos = $_POST['mem8pos']; $mem9 = $_POST['mem9']; $mem9pos = $_POST['mem9pos']; $mem0 = $_POST['mem0']; $mem0pos = $_POST['mem0pos']; $desc = $_POST['description']; $hometown = $_POST['hometown']; $errors = 0; if (!$bandName) { echo "<font color='red>You must enter a band name'</font>"; $errors++; } // ... and so on ... I hope you guys can spot the error Link to comment https://forums.phpfreaks.com/topic/43857-form-validation/ Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 To fix it do this for each line: $bandName = (isset($_POST['bandName']))?$_POST['bandName']:""; That should solve the problem. Link to comment https://forums.phpfreaks.com/topic/43857-form-validation/#findComment-213209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.