How to parse the feedback form in PHP

Source: Internet
Author: User

A website often has functions such as user registration forms. We can useIt is very easy to obtain form data in PHP. After a form is sent, each element in the form is assigned a value, which can be used like a common variable.

 
 
  1. <FORM name="myform" ACTION="process_form.php3" METHOD="POST">   
  2. <INPUT TYPE="TEXT" NAME="mytext" VALUE="Some Value">   
  3. </FORM> 

In process_form.php3, the variable $ mytext is assigned the input value-very simple! Similarly, you can obtain variable values from form elements such as the list box, multiple-choice box, single-choice, and button. The only thing you have to do is name every element in the form so that it can be referenced in the future.

Based on the feedback form method in PHP, we can generate a simple form containing three elements: name, email address, and message. After a browser sends a form, the browser reads data from the PHP page (sendfdbk. php3) of the form, checks whether the name is blank, and finally mails the data to you.

Form: form. php3

 
 
  1. <?   
  2. include("include/common.inc");   
  3. $title = "Feedback";   
  4. include("include/header.inc");   
  5. ?>   
  6. <P>   
  7. <FORM ACTION="sendfdbk.php3" METHOD="POST">   
  8. <INPUT TYPE="text" NAME="name" value="Your name" SIZE="20" MAXLENGTH="30">   
  9. <INPUT TYPE="text" MAXLENGTH="40" WIDTH="20" value="Your Email" NAME="email">   
  10. <BR>   
  11. <TEXTAREA ROWS="7" COLS="40" NAME="comment">   
  12. Your feedback on my home page.   
  13. </TEXTAREA>   
  14. <BR>   
  15. <INPUT TYPE="submit" VALUE="Send Feedback!">   
  16. </FORM>   
  17. </P>   
  18. <?   
  19. include("include/footer.inc");   
  20. ?>   

Processing Form of feedback form in PHP: sendfdbk. php3

 
 
  1. <?
  2. Include("Include/common. inc ");
  3. $Title="Feedback";
  4. Include ("include/header. inc ");
  5. If ($Name= "")
  6. {
  7. // Now I hate anonymous messages!
  8. Echo "Duh? How come you are anonymous? ";
  9. }
  10. Elseif ($Name= "Your name ")
  11. {
  12. // This viewer really does not want to be named!
  13. Echo "Hello?<B>Your name</B>Is supposed to be replaced
  14. Your actual name!</B>";
  15. }
  16. Else
  17. {
  18. // Output a polite thank-you message
  19. Echo"
  20. Hello, $ name.
  21. <BR>
  22. Thank you for your feedback. It is greatly appreciated.
  23. <BR>
  24. Thanking you
  25. <BR>
  26. $ MyName<BR>
  27. $ MyEmailLink
  28. ";
  29. // Finally mail it out
  30. Mail ($ MyEmail, "Feedback .","
  31. Name: $ name
  32. Email: $ email
  33. Comment: $ comment
  34. ");
  35. }
  36. Include ("include/footer. inc ");
  37. ?>

The above code is the full implementation of feedback forms in PHP.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.