rocky48 Posted March 26, 2018 Share Posted March 26, 2018 I am designing a form where the users input information to be stored on a database. All of the other inputs apart from the email post OK, but the email does not! The error is: Notice: Undefined index: email in /home/hp3-linc4-nfs2-y/555/1099555/user/htdocs/includes/renew1.php on line 19 Consequently the mysqli query does not succeed. Here is the section of code in the html file: <h1>Online Renewal Form</h1> <form action="includes/renew1.php" method="post"> <fieldset> <p><label for= "firstname"><b>Enter Firstname:</b></label> <input type="text" name="firstname" id="firstname" value="firstname" size="20" maxlength="20"/></p> <p><label for= "surname"> <b>Enter Surname: </b></label> <input type="text" name="surname" id="surname" value="surname" size="20" maxlength="40"/></p> <p><label for= "bmfa_no"> <b>Enter BMFA No:</b></label> <input type="text" name="bmfa_no" id="bmfa_no" value="BMFA_No" size="30" maxlength="80" /> </p> <p><label for= "road"> <b>Enter Road:</b></label> <input type="text" name="road" id="road" value="road" size="30" maxlength="80"/> </p> <p><label for="town"> <b>Enter Town:</b> </label> <input type="text" name="town" id="town" value="town" size="30" maxlength="80"/> </p> <p><label for="county"> <b>Enter County:</b></label> <input type="text" name="county" id="county" value="county" size="30" maxlength="80" /> </p> <p><label for= "pcode"> <b>Enter Post Code:</b></label> <input type="text" name="pcode" id="pcode" value="pcode" size="30" maxlength="80" /> </p> <p><label for="phone"> <b>Enter Phone No:</b></label> <input type="tel" name="phone" id="phone" value="phone" size="30" maxlength="80" /> </p> <p><label for="mobile"> <b>Enter Mobile No:</b></label> <input type="tel" name="mobile" id="mobile" value="mobile" size="30" maxlength="80" /> </p> <p><label for="email"> <b>Enter Email:</b></label> <input id="email" type="text"></p> <p><label for="date"><b>Enter Date of Birth:</b></label> <input id="date" type="date"> </p> </fieldset> <fieldset> <p><label><b>Do you wish that the club obtains your BMFA membership & Insurance: </b></label> (click on box to see the list) <SELECT name= "club_mem"> <option value="No">NO</option> <option value="Yes">YES</option> </SELECT><br><br> </fieldset> <fieldset> <p><label><b>Country Member: </b></label> (click on box to see the list) <SELECT name= "country_mem"> <option value="No">NO</option> <option value="Yes">YES</option> </SELECT><br><br> </fieldset> <fieldset> <p><label><b>Do you require training: </b></label> (click on box to see the list) <SELECT name= "train"> <option value="No">NO</option> <option value="Yes">YES</option> </SELECT><br><br> </fieldset> <fieldset><legend><b>The Amount to Pay</b></legend> <p><label><b>Membership Fees: </b></label> (click on box to see the list) <SELECT name= "subs_amount"> <option value="0">0</option> <option value="10.00">£10.00</option> <option value="13.00">£13.00</option> <option value="15.00">£15.00</option> <option value="17.00">£17.00</option> <option value="24.00">£24.00</option> <option value="27.00">£27.00</option> <option value="34.00">£34.00</option> <option value="44.00">£44.00</option> </SELECT><br><br> <b>Description of Fees</b><br><br> Social or Country members £10<br> Family Junior member £13<br> Junior Country member £17<br> Family Partner member £24<br> Junior Club member (Includes BMFA fees) £27<br> Family Senior member &£34<br> Senior Club member (Includes BMFA fees) £44<br> Family members must complete the renewal form if they want the club to sign them up for BMFA family membership.<br> If the family member has Country membership of BMFA they must enrol as a country member (£10). </p> </fieldset> <fieldset><legend><b>Please select the method of payment</b></legend> <p><label><b>Payment Method: </b></label> (click on box to see the list) <select name="pay_meth"> <option value="Cheque">Cheque</option> <option value="Cash">Cash</option> <option value="BACS">BACS</option> </select> </fieldset> <br /> <div align="left"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> The code in the PHP file is as follows: $trimmed = array_map('trim', $_POST); $Fname = mysqli_real_escape_string($dbc, $_POST['firstname']); $Sname = mysqli_real_escape_string($dbc, $_POST['surname']); $Road = mysqli_real_escape_string($dbc, $_POST['road']); $Town = mysqli_real_escape_string($dbc, $_POST['town']); $County = mysqli_real_escape_string($dbc, $_POST['county']); $Pcode = mysqli_real_escape_string($dbc, $_POST['pcode']); $Phone = mysqli_real_escape_string($dbc, $_POST['phone']); $Mobile = mysqli_real_escape_string($dbc, $_POST['mobile']); $Email = mysqli_real_escape_string($dbc, $_POST['email']); $DOB = mysqli_real_escape_string($dbc, $_POST['dob']); $BMFA = mysqli_real_escape_string($dbc, $_POST['bmfa_no']); $C_mem = mysqli_real_escape_string($dbc, $_POST['country_mem']); $Amount = mysqli_real_escape_string($dbc, $_POST['subs_amount']); $meth = mysqli_real_escape_string($dbc, $_POST['pay_meth']); $club = mysqli_real_escape_string($dbc, $_POST['club_mem']); $training = mysqli_real_escape_string($dbc, $_POST['train']); I thought that the problem was in the HTML file, but I am unable to see where it is incorrect. Please help? Quote Link to comment https://forums.phpfreaks.com/topic/306948-posting-email-in-a-form-undefined-index/ Share on other sites More sharing options...
dalecosp Posted March 26, 2018 Share Posted March 26, 2018 (edited) <input id="email"> also needs a name attribute. Perhaps more coffee? Edited March 26, 2018 by dalecosp Quote Link to comment https://forums.phpfreaks.com/topic/306948-posting-email-in-a-form-undefined-index/#findComment-1557416 Share on other sites More sharing options...
requinix Posted March 26, 2018 Share Posted March 26, 2018 Same for the date of birth. Quote Link to comment https://forums.phpfreaks.com/topic/306948-posting-email-in-a-form-undefined-index/#findComment-1557421 Share on other sites More sharing options...
cyberRobot Posted March 27, 2018 Share Posted March 27, 2018 You could simplify the code a bit. If you enclose the input field with the <label> tag, the "id" and "for" attributes are unnecessary. For example: <p><label><b>Enter Firstname:</b> <input type="text" name="firstname" value="firstname" size="20" maxlength="20"/></label></p> More information about the <label> tag can be found here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label Quote Link to comment https://forums.phpfreaks.com/topic/306948-posting-email-in-a-form-undefined-index/#findComment-1557438 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.