doudu8291
2014-01-14 03:13
浏览 28
已采纳

错误到我的PHP代码结束,我找不到它,我已经尝试了两天[关闭]

Link to basic functions file:

<?php require_once("functions.inc"); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <link rel="stylesheet" type="type/css" href="form.css"/>
    <title>Registration Page</title>
    </head>
    <body>
    <form id="userForm" method="POST" action="register-process.php">
    <div>

Registration Page:

    <fieldset>
            <legend>Registration Information</legend>
            <div id="errorDiv">

    <?php
            if (isset($_SESSION['error']) && isset($_SESSION['formAttempt'])) {
                    unset($_SESSION['formAttempt']);
                    print "Errors encountered<br />
";
                    foreach ($_SESSION['error'] as $error) {
                                    print $error . "<br />
";
                    } //end foreach
    ?>

    </div>

Registration Page Fields:

            <label for="fname">First Name:* </label>
                    <input type="text" id="fname" name="fname" />
                    <span class="errorFeedback errorSpan"
            id="fnameError"> First Name is required</span>
                    <br />
                    <label for="lname">Last Name:* </label>
                    <input type="text" id="lname" name="lname">
                    <span class="errorFeedback errorSpan"
            id="lnameError">Last Name is required</span>
                    <br />
                    <label for="email">E-mail Address:*</label>
                    <input type="text" id="email" name="email">
                    <span class="errorFeedback errorSpan"
            id="emailError">E-mail is required</span>
                    <br />
                    <label for="password1">Password:*</label>
                    <input type="password" id="password1" name="password1">                             <span class="errorFeedback errorSpan"
            id="password1Error">Password required</span>
                    <br /> 
                    <label for="password2">Verify Password:*</label>
                    <input type="password" id="password2" name="password2">
                    <span class="errorFeedback errorSpan"
            id="password1Error">Password required</span>
                    <br />
                    <label for="addr">Address: </label>
                    <input type="text" id="addr" name="addr">
                    <br />
                    <label for="city">City:</label>
                    <input type="text" id="city" name="city">
                    <br />
                    <label for="county">County:</label>
                    <select name="county" id="county">
                    <option></option>
                    <option value="Avon">Avon</option>
                    <option value="Bedfordshire">Bedfordshire</option>
                    <option value="Berkshire">Berkshire</option>
                    <option value="Borders">Borders</option>
                    <option value="Buckinghamshire">Buckinghamshire</option>
                    <option value="Cambridgeshire">Cambridgeshire</option>
                    <option value="Central">Central</option>
                    <option value="Cheshire">Cheshire</option>
                    <option value="Cleveland">Cleveland</option>
                    <option value="Clwyd">Clwyd</option>
                    <option value="Cornwall">Cornwall</option>
                    <option value="County Antrim">County Antrim</option>
                    <option value="County Armagh">County Armagh</option>
                    <option value="County Down">County Down</option>
                    <option value="County Fermanagh">County Fermanagh</option>
                    <option value="County Londonderry">County Londonderry</option>
                    <option value="County Tyrone">County Tyrone</option>
                    <option value="Cumbria">Cumbria</option>
                    <option value="Derbyshire">Derbyshire</option>
                    <option value="Devon">Devon</option>
                    <option value="Dorset">Dorset</option>
                    <option value="Dumfries and Galloway">Dumfries and Galloway</option>
                    <option value="Durham">Durham</option>
                    <option value="Dyfed">Dyfed</option>
                    <option value="East Sussex">East Sussex</option>
                    <option value="Essex">Essex</option>
                    <option value="Fife">Fife</option>
                    <option value="Gloucestershire">Gloucestershire</option>
                    <option value="Grampian">Grampaign</option>
                    <option value="Greater Manchester">Greater Manchester</option>
                    <option value="Gwent">Gwent</option>
                    <option value="Gwynedd County">Gwynedd County</option>
                    <option value="Hampshire">Hampshire</option>
                    <option value="Herefordshire">Herefordshire</option>
                    <option value="Hertfordshire">Hertfordshire</option>
                    <option value="Highlands and Islands">Highlands and Islands</option>
                    <option value="Humberside">Humberside</option>
                    <option value="Isle of Wight">Isle of Wight</option>
                    <option value="Kent">Kent</option>
                    <option value="Lancashire">Lancashire</option>
                    <option value="Leicestershire">Leicestershire</option>
                    <option value="Lincolnshire">Licolnshire</option>
                    <option value="Lothian">lothian</option>
                    <option value="Merseyside">Merseyside</option>
                    <option value="Mid Glamorgan">Mid Glamorgan</option>
                    <option value="Norfolk">Norfolk</option>
                    <option value="North Yorkshire">North Yorkshire</option>
                    <option value="Northamptonshire">Northhamptonshire</option>
                    <option value="Northumberland">Northumberland</option>
                    <option value="Nottinghamshire">Nottinghamshire</option>
                    <option value="Oxfordshire">Oxforshire</option>
                    <option value="Powys">Powys</option>
                    <option value="Rutland">Rutland</option>
                    <option value="Shropshire">Shropshire</option>
                    <option value="Somerset">Somerset</option>
                    <option value="South Glamorgan">South Glamorgan</option>
                    <option value="South Yorkshire">South Yorkshire</option>
                    <option value="Staffordshire">Staffordshire</option>
                    <option value="Strathclyde">Strathclyde</option>
                    <option value="Suffolk">Suffolk</option>
                    <option value="Surrey">Surrey</option>
                    <option value="Teesside">Teesside</option>
                    <option value="Tyne and Wear">Tyne and Wear</option>
                    <option value="Warwickshire">Warwickshire</option>
                    <option value="West Glamorgan">West Glamorgan</option>
                    <option value="West Midlands">West Midlands</option>
                    <option value="West Sussex">West Sussex</option>
                    <option value="West Yorkshire">West Yorkshire</option>
                    <option value="Wiltshire">Wiltshire</option>
                    <option value="Worcestershire">Worcestershire</option>
                    </select>
                    <br />
                    <label for="postcode">Postcode:</label>
                    <input type="text" id="postcode" name="postcode">
                    <br />
                    <label for="phone">Phone Number:</label>
                    <input type="text" id="phone" name="phone">
                    <span class="errorFeedback errorSpan"
            id="phoneError">Format: xxxx-xxx-xxxx</span>
                    <br />
                    <br />
                    <label for="mobile"> Number Type:</label>
                    <input class="radioButton" type="radio"        
            name="phonetype" id="mobile" value="mobile">  
                    <label class="radioButton" for="mobile">Mobile</label>
                    <input class="radioButton" type="radio"
            name="phonetype" id="home" value="home">
                    <label class="radioButton" for="home">Home</label>

Syntax error is apparently on this line according to Dreamweaver and the error was present from early on when writing the code and moved to the to the newer span class when a new one was added:

                    <span class="errorFeedback errorSpan phoneTypeError"        
            id="phonetypeError">Please choose an option</span>
                    <br />
                    <input type="submit" id="submit" name="submit">
                    </fieldset>

    </div>
    </form>
    </body>

When I attempt to view this page in a web browsers it suggests that there are issues with the last line:

    </html>

I have looked for errors but came seem to find any clear ones!

Hope I'm not being stupid

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • duanhui1185 2014-01-14 03:17
    已采纳

    You are using this twice

    <span class="errorFeedback errorSpan" id="password1Error">Password required</span>
    

    Remove one instance of that....

    Secondly , you forgot to close a brace for your if. Close it like this

    <?php
        if (isset($_SESSION['error']) && isset($_SESSION['formAttempt'])) {
            unset($_SESSION['formAttempt']);
            print "Errors encountered<br />
    ";
            foreach ($_SESSION['error'] as $error) {
                print $error . "<br />
    ";
            } //end foreach
         }//<----- Add here
            ?>
    
    已采纳该答案
    打赏 评论
  • douzhanshen0657 2014-01-14 03:15

    You're missing the closing bracket of your IF statement:

    <?php
            if (isset($_SESSION['error']) && isset($_SESSION['formAttempt'])) {
                    unset($_SESSION['formAttempt']);
                    print "Errors encountered<br />
    ";
                    foreach ($_SESSION['error'] as $error) {
                                    print $error . "<br />
    ";
                    } //end foreach
            } // <-- MISSING
    ?>
    
    打赏 评论
  • duanlv2788 2014-01-14 03:23

    add last brackets in your php code. because you use if statement and foreach..

    <?php
    
         if() {
         //enter code here
           foreach() {
           //enter code here
    
           }
         }
    ?>
    
    打赏 评论

相关推荐 更多相似问题