2012-03-08 81 views
0

尋找提交包含PHP代碼的表單的幫助。基本上我有一個textarea,我希望人們能夠提交代碼,然後這將通過電子郵件發送給我和格式化的方式。提交可能看起來像這樣的代碼:通過表單提交代碼片段

<?php print "Testing"; ?> 

我通過Ajax,我已經得到了所有工作的提交表單。然而,我的問題是,當我嘗試從textarea發送代碼時,該字段在我收到的電子郵件中是空白的。

我曾嘗試在發送之前用Ajax轉義字段,然後電子郵件包含大量轉義字符。

基本上我如何獲得正確發送的代碼並且看起來與在字段中輸入的一樣?


我試圖通過消除字符得到這個工作。我實際上使用.NET系統。有沒有特定的命令?

我後面的代碼看起來是這樣的:

[RestExtensionMethod()] 
    public static string CreateSnippet(int processid) 
    { 

     //here we find form values posted to the current page 
     HttpRequest post = HttpContext.Current.Request; 
     string email = post["email"]; 
     string comment = post["comment"]; 
     string name = post["name"]; 
     string website = post["website"]; 

     var mailcontent = new StringBuilder(); 
     mailcontent.AppendFormat(EmailLineFormat, "Name", name); 
     mailcontent.AppendFormat(EmailLineFormat, "Email", email); 
     mailcontent.AppendFormat(EmailLineFormat, "Website", website); 
     mailcontent.AppendFormat(EmailLineFormat, "Message", comment); 

     // Send the email 
     library.SendMail("[email protected]", "[email protected]", "Contact Form Enquiry", mailcontent.ToString(), true); 

     //if nothing gets created, we return zero 
     return "success"; 

    } 

我的jQuery看起來是這樣的:提前

// submit 
     $contactUsForm.submit(function() { 

      $loader.show(); 

          var url = "/base/Form4Umbraco/url.aspx"; 

          var name = jQuery("#tbName").val(); 
          var email = jQuery("#tbEmail").val(); 
          var website = jQuery("#tbWebsite").val(); 
          var comment = jQuery("#tbEnquiry").val(); 

          jQuery.post(url, { name: name, email: email, website: website, comment: comment }, 
           $contactUsSuccess.fadeIn() 
          ); 

      return false; 
     }); 

感謝您的幫助,非常感謝。 羅伯特

+0

過去了,我在你面前請發佈調用AJAX的jQuery代碼,以及發送電子郵件的PHP。 – 2012-03-08 13:37:42

+0

使用AJAX轉義? – 2012-03-08 13:39:59

+0

我已經添加了.net代碼和jQuery代碼。 – Robert 2012-03-08 19:31:49

回答

0

之前您的Ajax請求逃離PHP的代碼和你好像越來越簡單文本的電子郵件,然後從你的PHP腳本發送電子郵件UNESCAPE你的代碼從textarea的

+0

好吧,所以我需要在實際發送代碼之前再次使用代碼。我會給它一個鏡頭。 – Robert 2012-03-08 13:39:30

+0

無法啓動它,請參閱原文。 – Robert 2012-03-08 19:58:12