The concrete implementation method of the feedback form in PHP _php tutorial

Source: Internet
Author: User
A website often appears with user-registered functions such as filling out forms. We can passGetting the form data in PHP is simple. When a form is sent, the elements contained in the form are assigned the corresponding values, which can be used as a reference to a generic 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 given the input value-very simple! Similarly, you can get variable values from form elements such as list boxes, multi-box, radio boxes, buttons, and so on. The only thing you have to do is to name each element of the form so that it can be referenced in the future.

Based on the method of the feedback form in PHP, we can generate a simple form with three elements: name, e-mail address, and message. When the browser sends the form, the PHP page (sendfdbk.php3) that processes the form reads the data, checks to see if the name is empty, and finally sends the data mail to you.

Form: form.php3

 
 
  1. include ("Include/common.inc");
  2. $ title = "Feedback" ;
  3. Include ("Include/header.inc");
  4. ?>
  5. < P >
  6. < form action = " Sendfdbk.php3 " method = "POST" ;
  7. < input type = "text" name = "NAME" value = "Your name" size = "" maxlength = "+" span class= "tag" > ;
  8. < INPUT TYPE="text" MAXLENGTH="Max" WIDTH= " value"="Your Email" NAME="email">
  9. < BR >
  10. < TEXTAREA ROWS="7" COLS="Max" NAME = "comment" >
  11. Your feedback on my home page.
  12. TEXTAREA >
  13. < BR >
  14. < INPUT TYPE="Submit" VALUE="Send feedback! " >
  15. FORM >
  16. P >
  17. include ("Include/footer.inc");
  18. ?>

The processing form of the feedback form in PHP: SENDFDBK.PHP3

 
 
  1. include ("Include/common.inc");
  2. $ title = "Feedback" ;
  3. Include ("Include/header.inc");
  4. if ($name = = "")
  5. {
  6. Now I'm sick of anonymous messages!
  7. echo "Duh?" How come is anonymous? ";
  8. }
  9. ElseIf ($name = = "Your name")
  10. {
  11. The visitors really don't want to be named!
  12. echo "Hello?" <B> Your name B> is supposed to be replaced with
  13. your actual name! B> ";
  14. }
  15. Else
  16. {
  17. Output a polite thank you language
  18. echo "
  19. Hello, $name.
  20. < BR >
  21. Thank for your feedback. It is greatly appreciated.
  22. < BR >
  23. Thanking
  24. < BR >
  25. $MyName <BR>
  26. $MyEmailLink
  27. ";
  28. Finally Mail out
  29. Mail ($MyEmail, "Feedback.", "
  30. Name: $name
  31. E-mail: $email
  32. Comment: $comment
  33. ");
  34. }
  35. Include ("Include/footer.inc");
  36. ?>

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


http://www.bkjia.com/phpjc/446343. HTML www.bkjia.com true http://www.bkjia.com/phpjc/446343.html techarticle A website often has features such as filling out forms that are registered by users. It is easy for us to get the form data through PHP. When a form is sent, the form contains ...

  • 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.