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.
- <FORM name="myform" ACTION="process_form.php3" METHOD="POST">
- <INPUT TYPE="TEXT" NAME="mytext" VALUE="Some Value">
- 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
-
- include("include/common.inc");
- $title = "Feedback";
- include("include/header.inc");
- ?>
- <P>
- <FORM ACTION="sendfdbk.php3" METHOD="POST">
- <INPUT TYPE="text" NAME="name" value="Your name" SIZE="20" MAXLENGTH="30">
- <INPUT TYPE="text" MAXLENGTH="40" WIDTH="20" value="Your Email" NAME="email">
- <BR>
- <TEXTAREA ROWS="7" COLS="40" NAME="comment">
- Your feedback on my home page.
- TEXTAREA>
- <BR>
- <INPUT TYPE="submit" VALUE="Send Feedback!">
- FORM>
- P>
-
- include("include/footer.inc");
- ?>
Processing form of feedback form in PHP: sendfdbk. php3
-
- Include("Include/common. inc ");
- $Title="Feedback";
- Include ("include/header. inc ");
- If ($Name= "")
- {
- // Now I hate anonymous messages!
- Echo "Duh? How come you are anonymous? ";
- }
- Elseif ($Name= "Your name ")
- {
- // This viewer really does not want to be named!
- Echo "Hello?<B>Your name B>Is supposed to be replaced
- Your actual name! B>";
- }
- Else
- {
- // Output a polite thank-you message
- Echo"
- Hello, $ name.
- <BR>
- Thank you for your feedback. It is greatly appreciated.
- <BR>
- Thanking you
- <BR>
- $ MyName<BR>
- $ MyEmailLink
- ";
- // Finally mail it out
- Mail ($ MyEmail, "Feedback .","
- Name: $ name
- Email: $ email
- Comment: $ comment
- ");
- }
- Include ("include/footer. inc ");
- ?>
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...