How to parse the feedback form in PHP _ PHP Tutorial

Source: Internet
Author: User
Parse the specific implementation of feedback forms in PHP. A website often has functions such as user registration forms. It is very easy to obtain form data through PHP. When a form is sent, a website contained in the form will often have a user-registered form filling function. 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. 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="20" MAXLENGTH="30">
  8. <INPUT TYPE="text" MAXLENGTH="40" WIDTH="20" value="Your Email" NAME="email">
  9. <BR>
  10. <TEXTAREA ROWS="7" COLS="40" 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. ?>

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

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


Bytes. It is very easy to obtain form data through PHP. When a form is sent...

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.