首页 > 解决方案 > 用 PHP 显示 html 输入的数据

问题描述

下面是我的 HTML 和 PHP 代码。我正在尝试显示我输入的数据,但是,我什么也没得到。我的代码有什么问题?

HTML

<form action="welcome.php" method="POST">
        <fieldset>
            <legend> Personal Details: </legend>
                <label for="fname>"></label>
                    <input type="text" name="Name" id="fname" required autofocus placeholder="First Name" pattern="[a-zA-Z]{3,}" title="Please enter more than three letters">
                <label for="lname>"></label>
                    <input type="text" name="Last Name" id="lname" required autofocus placeholder="Last Name" pattern="[a-zA-Z]{3,}" title="Please enter more than three letters">
                <label for="email">Email: </label>
                    <input type="text" name="email" id="email" required placeholder="Your school email" pattern="[a-zA-Z]{3,}@[a-zA-Z]{3,}[.]{1}[a-zA-Z{2} title="Please enter a valid email address>
                <label for="phone">Phone: </label>
                    <input type="tel" name="phone" id="phone" required placeholder="Please enter in your phone number" pattern="[0-9]{4} [0-9]{3} [0-9]{3}" title="Please enter in a phone number in this format: #### ### ###">
            <select name="country" required>
                <option value=""> </option> 
                <option value="US">US</option>
                <option value="UK">UK</option>
                <option value="AUS">AUS</option>
            </select>
        </fieldset>
        <br>
        <fieldset>
            <legend> Booking Details: </legend>
            <input type="date" name="date" min="2018-10-07" max="2018-10-31">
            <input type=time min=9:00 max=17:00 step=900> 
            <br>
            <br>
            <label for="dorm">Dormitory: </label>
            <br>
            <select name="dorm" required>Dormitory
                <option value="Cypress">Cypress Hall</option>
            </select>
            <br>
            <br>
            <label for="floor">Floor: </label>
            <br>
            <select name="floor" required>Floor: 
                <option value=""></option>
                <option value="02">02</option>
                <option value="03">03</option>
                <option value="04">04</option>
                <option value="05">05</option>
                <option value="06">06</option>
                <option value="07">07</option>
                <option value="08">08</option>
            </select>
            <br>
            <br>
            <label for="roomnumber">Room Number: </label>
            <br>
            <select name="roomnumber">Room Number: 
                <option value=""></option>
                <option value="22">22</option>
            </select>
            <br>
            <br>
            <label for="roomletter">Room Letter: </label>
            <br>
            <select name="roomletter" required="">Room Letter
                <option value=""></option>
                <option value="A">A</option>
                <option value="B"> B</option>
            </select>
            <br>
            <br>
            <label for="bedroomcleaning">Bedroom: </label><br>
            <input type="checkbox" id="box-4" onclick="checkPrice()" value="4">Dust all ceiling fans/light/fixtures within reach.<br>
            <input type="checkbox" id="box-5" onclick="checkPrice()" value="5"> Change sheets and/or fold clothes if requested by client.<br>
            <input type="checkbox" id="box-6" onclick="checkPrice()" value="6"> Straighten up, put toys away, make beds, fold clothes and put on bed. Straighten papers and put in a pile. DO NOT THROW AWAY ANY PERSONAL ITEMS!<br><br>
            <label for="bathroomcleaning">Bathroom: </label><br>
            <input type="checkbox" id="box-1" onclick="checkPrice()" value="1"> Clean bowl and wipe down toilet cover, seat, under seat, base and behind the base.<br>
            <input type="checkbox" id="box-2" onclick="checkPrice()" value="2"> Clean all mirrors.<br>
            <input type="checkbox" id="box-3" onclick="checkPrice()" value="3"> Clean countertops and backsplashes.<br>
            <label for="bathroomprice" id="price">Total Price: </label>

            <br>
            <br>
            <input type="submit">
        </fieldset>
        </form>

PHP

Welcome <?php echo $_POST["Name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
Your phone number is: <?php echo $_POST["phone"]; ?>

标签: phphtml

解决方案


检查您的电子邮件输入模式:

[a-zA-Z]{3,}@[a-zA-Z]{3,}[.]{1}[a-zA-Z{2}

[a-zA-Z]{3,}@[a-zA-Z]{3,}[.]{1}[a-zA-Z]{2}

还:

<input type=time min=9:00 max=17:00 step=900> 

<input type="time" min="9:00" max="17:00" step="900"> 

推荐阅读