PHP開發經驗總結

做之前要先明確目標,了解到底要實現什麼功能,然後根據功能設計前端頁面。

對於頁面的排版佈局製作之前,可以在紙上畫出來大概的樣式,然後再寫。

當所有需要的頁面做完以後再寫PHP程式碼去實作功能。

功能要一個一個做,做完一個再做下一個。程式碼的書寫原則是在功能實現的前提下,程式碼越簡潔越好。

對於路徑的引用,要正確,不然引用不成功。

繼續學習
||
<?php session_start(); header("content-type:text/html;charset=utf-8"); //连接数据库 $link = mysqli_connect("localhost","root","root","regedit"); if (!$link) { die("连接失败: " . mysqli_connect_error()); } if(isset($_POST)){ //用户名不能为空 if(!$_POST['username']){ echo('用户名不能为空'); return; } //密码不能为空 if(!$_POST['password']){ echo('密码不能为空'); return; } //判断验证码是否填写并且是否正确 if(!$_POST['code']){ echo('验证码不能为空'); return; }else if($_POST['code']!=$_SESSION['VCODE']){ echo('验证码不正确'); return; } $sql="select username,password from form where username = '{$_POST['username']}' and password='{$_POST['password']}'"; $rs=mysqli_query($link,$sql); //执行sql查询 $row=mysqli_fetch_assoc($rs); if($row) { // 用户存在; if ($username == $row['username'] && $pwd == $row['password']) { //对密码进行判断。 echo "登陆成功,正在为你跳转至后台页面"; //header("location:index.php"); } }else{ echo "账号或密码错误" . "<br/>"; echo "<a href='login.html'>返回登陆页面</a>"; } }
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!