❶ 求写个比较简单的php登陆页面代码
主页面:index.php <form name="form1" action="login.php" method="post" onsubmit="return check()"><!--这里注意onclick的用法-->
账号:<input name="adminAccount" type="text" />
密码:<input type="password" name="adminPass" />
输入验证码:<input type="text" name="validate" />
< br />
<input type="submit" value="登陆" /><input type="reset" value="重置">
</form>判断页面:login.php<?php
//再连库判断账号密码
require_once("../inc/dbconfig.php");
$adminAccount=$_POST['adminAccount'];
$adminPass=md5($_POST['adminPass']);
$sql="select * from admin where adminAccount='$adminAccount' and adminPass='$adminPass'";
$result=mysql_query($sql) or die($sql);
$rows=mysql_num_rows($result);
if($rows==0){
?>
<script language="javascript">
alert("管理员账号密码错误!");
window.location="index.php";
</script>
<?
exit();
}
//将管理员账号赋值给session
$_SESSION['adminAccount']=$adminAccount;
?>
<script language="javascript">
window.location="command.php";
</script>配置文件自己来就行了!
❷ 简单PHP代码
$_env 是环境变量,通过环境方式传递给当前脚本的变量的数组。
$_ENV['defaultapp'] = array('portal.php' => 'portal', 'forum.php' => 'forum', 'group.php' => 'group', 'home.php' => 'home');
是赋值 , 你可以用 var_mp($_env['defaultapp']) 看赋值结果。
--------------------------------------------------------------------
$_ENV['hostarr'] = explode('.', $_SERVER['HTTP_HOST']);
环境变量 用.分隔 主域名(你可以 echo $_server['HTTP_HOST']里面有什么)
----------------------------------------------------------------
$url = $domainroot.'forum.php?mod=group&fid='.$domain['id'].'&page=1';
构造一个URL 直白点 结果就是: www.some.com/forum.php?mod=1&fid=1&page=1
----------------------------------------
$url = empty($_ENV['domain']['app']['default']) ? (!empty($_ENV['domain']['defaultindex']) ? $_ENV['domain']['defaultindex'] : 'forum.php') : 'http://'.$_ENV['domain']['app']['default'];
结构简化 $url = $a ? (!$b? $c : $d) :$e; 2个3元运算嵌套, 至于看起来复杂的变量都是多维数组的值
❸ 求第一次接触php语言的最经典,最简单的源代码!!!!!!!!!!
<?php
//双斜杠为注释,在php中被解析不执行。每句要以 ‘分号’结束。
echo “hello world"; //echo表示输出
echo phpinfo(); //查看安装环境信息
//变量输出
$a='1'; //定义变量$a,用$符号表示
echo $a; //打印输出变量$a;
//数组定义
$arr = array(); //定义一个空数组
$arr1= array(1,2); //表示键值0=>1,1=>2
print_r($arr1); //打印数组元素
?>
php程序要以<?php ..... ?>未开始结束。 建议初学时根据 php中文手册 来学习。
❹ 最简单 php 代码
<?php
mysql_query("insert into guahao values('".$name."','".$nl."','".$shouji."','".$sname."','".$info."')");
?>
❺ php最经典,最基础的代码,适合入门的
PHP是一种可以嵌入到HTML中的运行在服务器端的脚本语言,所以为了体现PHP的特性我们可以分两种模式来实现PHP代码
1、 PHP嵌入到HTML中,例如index.php
<html>
<head></head>
<body>
<!--因为PHP嵌入到HTML中,所以需要完全区分PHP代码和HTML代码-->
<?php
//输出helloworld
echo'helloworld;
?>
</body>
</html>
2、 PHP独立文件,只有PHP代码,例如index.php
<?php
//输出
echo'helloworld';
//不需要闭合标签
❻ 求一段简单php代码
<?php
$temp="开头";
for($i=1;$i<5;$i++){
$temp.="class".$i;
}
$temp.="结尾";
echo $temp;
?>
❼ 求个简单的php代码
_tags($string, $replace_with_space = true)
{
if ($replace_with_space) {
return preg_replace('!<[^>]*?>!', ' ', $string);
} else {
return strip_tags($string);
}
}
截取字符函数(匹配各种编码)
function truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false){
if ($length == 0)
return '';
if (is_callable('mb_strlen')) {
if (mb_detect_encoding($string, 'UTF-8, ISO-8859-1') === 'UTF-8') {
// $string has utf-8 encoding
if (mb_strlen($string) > $length) {
$length -= min($length, mb_strlen($etc));
if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/u', '', mb_substr($string, 0, $length + 1));
}
if (!$middle) {
return mb_substr($string, 0, $length) . $etc;
} else {
return mb_substr($string, 0, $length / 2) . $etc . mb_substr($string, - $length / 2);
}
} else {
return $string;
}
}
}
// $string has no utf-8 encoding
if (strlen($string) > $length) {
$length -= min($length, strlen($etc));
if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
}
if (!$middle) {
return substr($string, 0, $length) . $etc;
} else {
return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2);
}
} else {
return $string;
}
}
综合就是
$arc=strip_tags($arc);
$arc=truncate($arc,200)
❽ 求很简单的PHP代码
<?php
$folder="C:wampwwwd";
$fp=opendir($folder);
while(false!=$file=readdir($fp)){
if($file!='.'&&$file!='..'){
$file="$folder/$file";
$arr_file[]=$file;
}
}
if(is_array($arr_file)){
while(list($key,$value)=each($arr_file)){
echo$value;
$key=file_get_contents($value);
$_patten='/(1234567)/';
if(preg_match($_patten,$key)){
$a=preg_replace($_patten,"7654321",$key);
file_put_contents($value,$a);
}
}
}
closedir($fp);
?>
代码就敲到到这了,感觉有点头痛,正则替换的7654321,你可以定义strrev($1);
❾ 修改一下简单的PHP代码!谢谢啦
<?php
if($_POST)
{
$dir=$_POST['dir'];
$content=$_POST['content'];
if(!file_exists($dir))
{
mkdir($dir);
}else{
echo"<script>alert('添加失败!')</script>";exit();
}
$url=$dir."/".$dir."txt";
$hd=fopen($url,"w");
if(fwrite($hd,$content))
{
echo"<script>alert('添加成功!')</script>";
}
else
{
echo"<script>alert('添加失败!')</script>";
}
fclose($hd);
}
else
{
?>
<!--<formmethod="post"action="<?phpecho$_SERVER['PHP_SELF']?>">
<inputtype="text"name="dir">文件夹名字
<inputtype="text"name="content">内容
<inputtype="submit"value="提交">
</form>-->
<?php
}
?>
代码已帮你修改了