2013-04-09 16 views
-1

的價值這是我的代碼,所有<input>標籤的問題,任何一個可以告訴我收到錯誤,這是整合HTML和PHP在呼應POST

<div style="width:115px; padding-top:10px;float:left;" align="left">Email Address:</div> 
<div style="width:300px;float:left;" align="left"> 

<input type="text" name="email" id="email" value="<?php echo strip_tags($_POST["email"]); ?>"  class="vpb_textAreaBoxInputs"></div><br clear="all"><br clear="all"> 
+0

什麼錯誤或發出你從這個代碼的故事嗎? – 2013-04-09 13:02:51

+0

請嘗試創建一個簡潔的標題來解釋問題,而不僅僅是代碼。 – andyb 2013-04-09 13:03:20

+0

注意:未定義指數:姓在C:\瓦帕\ WWW \ Saravanan \ PHP \ signup_and_login_with_php \ signup.php上線69調用堆棧#TimeMemoryFunctionLocation 10.0031391424 {主}().. \ signup.php:0 「類=」 vpb_textAreaBoxInputs 「> – user2219660 2013-04-09 13:03:54

回答

0

使用ternary operator顯示默認值的正確方法對於每個input代替

<input type="text" name="email" id="email" value="<?php echo isset($_POST['email'])?strip_tags($_POST['email']):''; ?>" class="vpb_textAreaBoxInputs"></div><br clear="all"><br clear="all"> 

相同爲firstname

<input type="text" name="firstname" id="firstname" value="<?php echo isset($_POST['firstname'])?strip_tags($_POST['firstname']):''; ?>" > 
+0

這是沒有問題的,如果POST [「郵件」]存在,他不檢查。 – 2013-04-09 13:08:34

+0

嗨,請看看吧,」類=‘vpb_textAreaBoxInputs’> – user2219660 2013-04-09 13:17:20

+0

姓名和電子郵件都得到同樣的錯誤! – user2219660 2013-04-09 13:18:02

2

你需要確保$_POST["email"]被使用爲之前設置您可以使用isset()

<?php if(isset($_POST["email"])) { echo strip_tags($_POST["email"]); }else{echo 'default' ;} ?> 
+0

我這樣做,另外我清潔香港與分貝值的組。請參閱這是如果(isset($ _ POST [「提交」])&& $ _POST [「提交」] ==「是」) – user2219660 2013-04-09 13:13:40

+0

是的罰款..你可以這樣做,但要確保你總是首先檢查元素設置之前檢查具體的價值,就像你在評論 – 2013-04-09 13:15:49

+0

錯誤(注意:未定義的索引:名字)中所做​​的那樣意味着當你嘗試使用它時沒有設置用戶名。所以你還是不檢查所有變量。 – 2013-04-09 13:18:35