[英]keep form value after submit it
我知道有很多其他問題,我在網上找到了1.000答案,但沒有一個與我的代碼一起工作:(那么有人可以幫助我如何在提交后保持電子郵件價值?
<form name="login-registration" onSubmit="return validateForm()" method="post" action="" >
<label>Email</label>
<input type="email" name="emailinput" id="emailinput" value ="" />
<p id="emptyEmail" class="hidden">Email field is required</p>
<p id="invalidEmail" class="hidden">Email you insert is invalid!</p>
<label>Your password</label>
<input type="password" name="pswinput" id="pswinput" value=""/>
<p id="pswMinMax" class="hidden">Password should be from 4 to 8 caracters</p>
<p id="pswLettNum" class="hidden">Password should be letters and numbers. No special caracters are allow</p>
<label>Repeat password</label>
<input type="password" name="pswrepeatinput" id="pswrepeatinput" value="" onblur="isValidPswRep()"/>
<p id="pswR" class="hidden">Your passwords is different</p>
<input type="checkbox" id="policy" name="policy" value="policy" /> <label>I agree</label>
<p id="checkN" class="hidden">You must agree to our term</p>
<input type="submit" name="submit" value="Login" />
</form>
我試着把一些代碼放在:
<input type="email" name="emailinput" id="emailinput" value = "<?php echo htmlspecialchars($_GET['lastname']); ?>" />
但是那個php行只顯示在字段輸入中。
嘗試使用$_POST['lastname']
而不是$_GET['lastname']
1)如果我沒錯,我在上面的代碼中看不到任何名稱=“lastname”的字段。
2)使用$ _POST,因為您使用method =“post”發布表單數據。
假設你的文件有.php
作為擴展名並且你的服務器上安裝了php,我希望你注意到你有一個錯誤,因為你使用POST
表單,而當你在輸入字段中應用value
,你試圖使用$_GET
進一步您沒有將lastname
分配給任何輸入字段,因此在應用此字段name="emailinput"
使用emailinput
。 你應該改變htmlspecialchars($_GET['emailinput']);
成為htmlspecialchars($_POST['emailinput']);
所以你的代碼看起來像這樣
<input type="email" name="emailinput" id="emailinput" value = "<?php echo htmlspecialchars($_POST['emailinput']); ?>" />
這應該在輸入字段中打印您的變量
那里至少有兩個問題。
php顯示為內聯的事實表明你有錯誤的文件擴展名(如建議的評論),你的“知道如何通過php閱讀”中沒有包含任何文件(因為沒有更好的方式來說,我的英語不完美)目錄。
當你發一個帖子時你回復了一個獲得(如其他答案所示)
另外......為什么你的問題有JS標簽(對不起蓋帽,想確定它突出)?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.