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.
- < 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 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
-
- 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 = "" maxlength = "+" span class= "tag" > ;
- < INPUT TYPE="text" MAXLENGTH="Max" WIDTH= " value"="Your Email" NAME="email">
- < BR >
- < TEXTAREA ROWS="7" COLS="Max" NAME = "comment" >
- Your feedback on my home page.
- TEXTAREA >
- < BR >
- < INPUT TYPE="Submit" VALUE="Send feedback! " >
- FORM >
- P >
-
- include ("Include/footer.inc");
- ?>
The processing form of the feedback form in PHP: SENDFDBK.PHP3
-
- include ("Include/common.inc");
- $ title = "Feedback" ;
- Include ("Include/header.inc");
- if ($name = = "")
- {
- Now I'm sick of anonymous messages!
- echo "Duh?" How come is anonymous? ";
- }
- ElseIf ($name = = "Your name")
- {
- The visitors really don't want to be named!
- echo "Hello?" <B> Your name B> is supposed to be replaced with
- your actual name! B> ";
- }
- Else
- {
- Output a polite thank you language
- echo "
- Hello, $name.
- < BR >
- Thank for your feedback. It is greatly appreciated.
- < BR >
- Thanking
- < BR >
- $MyName <BR>
- $MyEmailLink
- ";
- Finally Mail out
- Mail ($MyEmail, "Feedback.", "
- Name: $name
- E-mail: $email
- Comment: $comment
- ");
- }
- Include ("Include/footer.inc");
- ?>
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 ...