Recently, as a result of the project needs, from a front-end to the back end, have to do the backstage work. Think of me as the great goal of the whole stack of engineers, more determined their own drive. Although I have seen Nodejs before, but really used the background language or only PHP, so chose the language of PHP to colleagues to write backstage. I feel that I write PHP is simply to meet the basic needs, but also to keep learning.
In the process of completing the project, the mobile-side developers asked them to request the same URL each time, and then my side based on the different parameters in the background to achieve jump, request the corresponding PHP. It was better to ask for a different request for PHP than it was before.
So how to implement a jump between PHP. I am using header () to achieve, nonsense not much to say, directly on the code:
$serversName =$_post[' Serversname '];
if ($serversName = = ' Register ') {@ $phoneNumber =$_post["PhoneNumber"];
@ $password =$_post["password"];
@ $nickName =$_post["nickname"];
@ $userId = "Panaiduan";
@ $headImg =$_post["headimg"];
@ $token = "ABCDEFGHIJKLMN";
@ $deviceId =$_post["DeviceId"];
@ $clientOS =$_post["Clientos"]; Header (' location:register.php?phonenumber= '. $phoneNumber. ' &password= '. $password. ' &nickname= '. $nickName. ' &userid= '. $userId. ' &headimg= '. $headImg. ' &token= '. $token. ' &deviceid= '. $deviceId. '
&clientos= '. $clientOS);
}else if ($serversName = = ' Login ') {$phoneNumber =$_post["PhoneNumber"];
$password =$_post["Password"]; Header (' location:login.php?phonenumber= '. $phoneNumber. '
&password= '. $password);
}else if ($serversName = = ' Applyroom ') {$roomName =$_post["roomname"];
$channelId =$_post["Channelid"];
$roomDescribe =$_post["Roomdescribe"];
$timeStart =$_post["Timestart"]; $timeEnd=$_post["Timeend"];
$newscast =$_post["newscast"]; Header (' Location:createroom.php?roomname= '. $roomName. ' &channelid= '. $channelId. ' &roomdescribe= '. $roomDescribe. ' ×tart= '. $timeStart. ' &timeend= '. $timeEnd. '
&newscast= '. $newscast);
}else if ($serversName = = ' Getroom ') {$phoneNumber =$_post[' phonenumber '];
Header (' location:getroominfo.php?phonenumber= '. $phoneNumber);
}else if ($serversName = = ' password ') {$phoneNumber =$_post["PhoneNumber"];
$password =$_post["Password"]; Header (' location:resetpassword.php?phonenumber= '. $phoneNumber. '
&password= '. $password);
}else if ($serversName = = ' Modifyinfo ') {$phoneNumber =$_post["PhoneNumber"];
$nickName =$_post["nickname"]; Header (' location:modifyinfo.php?phonenumber= '. $phoneNumber. '
&nickname= '. $nickName); }This is the index.php code that requests the page every time they request it.
Each request has a serversname parameter that represents the purpose of the request and is defined in advance with the mobile end person. According to the value of the Serversname, the corresponding jump.
Header (' url ');
The parameter URL in the header is the page that you want to jump to, and if you want to pass the parameter over, You can use the Get method to pass the request parameters index.php to the target page, there is a problem to note that the request to index.php is the Post method request, index.php jump to the target page is get way to pass the parameter, in the target page to receive parameters to note.
Header (' location:login.php?phonenumber= '. $phoneNumber. ' &password= '. $password);
Pass the two parameters as above.
This approach is a bit like nodejs inside the route, my index.php by judging the parameters inside the serversname of the different to jump to the corresponding PHP page, and will be in addition to Serversname parameters continue to pass past. Because I have just been in PHP development, know not much, there are any problems are welcome to point out.
The header () to jump to solve the project needs, it feels good.