2018.6.16 PHP Small Experiment

Source: Internet
Author: User

PHP Experimental Experiment One
<?php/** * Created by Phpstorm. * User:qichunlin * DATE:2018/5/17 * Time: PM 5:35 */echo "Please enter the number to sort:<br/>"; echo "<form method=post>";//Loop Generate text    box for ($i = 1; $i < 6; $i + +) {//text box name is array name echo "<input type= ' text ' name= ' stu[] ' size= ' 5 ' >";    if ($i < 5) {echo "-";    }} echo "<input type= ' submit ' name= ' BT ' value= ' submitted ' > ';    echo "</form>";        if (Isset ($_post[' BT ')) {$temp = 0;        $stu = $_post[' Stu ');        $num = count ($stu);        echo "The data you have entered is <br/>"; foreach ($stu as $score) {echo $score.        "<br>"; } for ($i = 0; $i < $num, $i + +) for ($j = $i + 1; $j < $num; $j + +) {if ($stu [$i] & Gt                    $stu [$j]) {$temp = $stu [$i];                    $stu [$i] = $stu [$j];                $stu [$j] = $temp;    }} echo "The sorted data is shown below:<br/>"; Use while loop to iterate through an array while (list ($key, $value) = each ($stu)) {//Outputs the sorted array echo $value.    "<br/>"; }}?>
Experiment Two
<?php/** * Created by Phpstorm. * User:qichunlin * DATE:2018/5/17 * Time: PM 6:10 */echo "Please enter the study number:<br/>"; echo "<form method= ' post ' >"; for ($i = 1; $i < 6;    $i + +) {//The name of the text box is the array name echo "<input type= ' text ' name= ' stu[] ' size= ' 6 ' >"; if ($i < 5) echo "-";}    echo "<input type= ' submit ' name= ' BT ' value= ' submitted ' >", echo "</form>"; if (Isset ($_post[' BT ')) {//echo "123";    $k = 0;    $JSJ = Array ();    $stu = $_post[' Stu '); for ($i = 0; $i < count ($stu), $i + +) for ($j = $i + 1; $j < count ($stu); $j + +) {if (strcmp ($stu [$        I], $stu [$j] = = 0) array_splice ($stu, $j, 1);    } $STR = Implode (",", $stu);    echo "All students study number as follows:</br>"; Echo $str.    "<br>"; foreach ($stu as $value) {if (Strstr ($value, "0811")) {$string = Str_replace ("08121", "08110", $value)            ;            $JSJ [$k] = $string;        $k + +;    }} echo "The computer professional study number is as follows:</br>"; Echo Implode (",", "$JSJ ");}? >
Experiment Three

<?php
/**

    • Created by Phpstorm.
    • User:qichunlin
    • Date:2018/5/17
    • Time: 4:36
      */
      if (Isset ($_post[' GO ')) {
      $id = $_post[' id '];
      $pwd = $_post[' pwd '];
      $birthday = $_post[' birthday ');
      $Email = $_post[' Email '];
      Check to see if it is a 6~12 character
      $checkId = Preg_match ('/^\w{6,12}$/', $id);
      Check if it is a 6~20 number
      $CHECKPWD = Preg_match ('/^\d{6,20}$/', $pwd);
      Check if it is a valid date
      $checkBirthday = Preg_match ('/^\d{4}-(0?\d|1?[ 012])-(0?\d|3[01]) $/', $birthday);
      Check the legality of email address
      $checkEmail = Preg_match ('/^[a-za-z0-9_-][email protected][a-za-z0-9-]+.[ a-za-z0-9-.] +$/', $Email);

      if (! $checkId)
      echo "";
      else if (! $checkPwd)
      echo "";
      else if (! $checkBirthday)
      echo "";
      else if (! $checkEmail)
      echo "";
      Else
      echo "registered successfully!";
      }
      ?>
      ```

Experiment Four
<!    DOCTYPE html><!--HTML5 form--><style type= "text/css" > table, Div, TD {Text-align:center;    } table {margin:0 auto;        } p {font-size:18px;    Color: #FF0000;                }</style><form name=fr1 method=post> <table border=1> <tr> <td>            <div> number </div> </td> <td> <div> name </div> </td> <td> <div> results </div> </td> </tr&        Gt         <?php/** * Created by Phpstorm.            * User:qichunlin * date:2018/5/20 * Time: PM 2:56 */for ($i = 1; $i < 5; $i + +) { ?> <tr> <td><input type=text name= "xh[]" ></td> & Lt;td><input typet=text name= "xm[" ></td> <td><input type=text Name= "cj[" ></td> </tr> <?php}?> <tr> &LT;TD colspan= "3" ><input type= "Submit" Name= "Bt_stu" value= "Submit" ></td> </tr> </table>    </form><p align=center> Note that the study number value cannot be repeated </p><?phpif (Isset ($_post[' Bt_stu ')) {$XH = $_post[' XH '];    $XM = $_post[' XM '];    $CJ = $_post[' CJ '];    Array_multisort ($CJ, $XH, $XM);    for ($i = 0; $i < count ($XH), $i + +) $sum [$i] = Array ($XH [$i], $XM [$i]);    echo "<div> after sorting the score table below:</div>"; echo "<table border=2><tr><td> No. </td><td> name </td><td> score </td></    Tr> ";        foreach ($sum as $value) {list ($stu _number, $stu _name, $stu _score) = $value; echo "<tr><td> $stu _number</td><td> $stu _name</td><td> $stu _score</td>            </tr> ";    } echo "</table><br/>";    Reset ($sum); while (List ($key, $value) = each ($sum)) {list ($stu _number, $stu _name, $stu _score) = $value;            if ($stu _number = = "3") {echo "<p align=center>"; Echo $stu _number. "The name is:". $stu _name.            ","; echo "score is:".            $stu _score;        Break }}}?>
Experiment Five
<!        DOCTYPE html><!--HTMl5 form--><style type= "Text/css" > P {font-family: "Founder Shu Body";    Text-align:center;        } div {font-family: "bold";    Text-align:center; }</style><form name= "F1" action= "method=" POST "> <p> your email address: <br><input type=" text "Name=" Email "size=" ><br> your message: <br><textarea name= "note" rows= "ten" cols= "></textarea"    > <br><input type= "Submit" Name= "BT1" value= "submit" ><input type= "reset" name= "BT2" value= "Empty" > </p></form><?php/** * Created by Phpstorm. * User:qichunlin * date:2018/5/20 * Time: PM 6:37 */if (isset ($_post[' bt1 ')) {//Receive email address $Email = $_post[' email '    ];    $note = $_post[' Note ']; Determine whether to get the value if (! $Email | |! $note) echo "<script>alert (' Eamil address and message please complete!    ') </script> ";        else {//split Email address $array = explode ("@", $Email); If there are two @ symbols then an error if (COUNT ($array)! = 2) echo "<script>alert (' email address format is wrong!        ') </script> ";            else {//Get the content in front of @ $username = $array [0];            Get the content after @ $netname = $array [1]; If the username contains "." Or "," will error if (Strstr ($username, ".") or Strstr ($username, ",")) echo "<script>alert (' email Incorrect address format!            ') </script> "; else {$str 1 = htmlspecialchars ("<");//Output symbol "<" $str 2 = Htmlspecialchars (">");//output symbol                ">" $newnote = Str_replace ("I", "I", $note);                XSS attacks can be converted into HTML entity form to solve $newnote =htmlspecialchars ($newnote);                echo "<div>"; echo "User". $str 1. $username. $str 2. Hello!                &nbsp; "; echo "You are". $username. Netizens                <br> "; echo "<br> your message is:<br>&nbsp;&nbsp;&nbsp;". $newnote.                "<br>";            echo "</div>"; }        }    }}?> 

2018.6.16 PHP Small Experiment

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.