php学习日记
1.数据库连接$conn=mysql_connect("localhost","root","");
mysql_select_db("baoming");
mysql_query("set names gbk");
-------------------------------------------------------------------
2。smarty,fck配置。
-------------------smarty配置:-------------------------------
------------------fck配置--------------------------------------------
----------------------------------------------------------------------
3。查,插,改,删,
--------------查询(一维数组)------------------------------------
----------------------------------------------------------------------------------
6,缩略图
------------------------------------------------------------------------------------------------------------------
$file_name为图片的路径
$img=null;
$ext=strtolower(end(explode(".",$file_name)));
if($ext == 'jpg' || $ext == 'jpeg'){//判断图片的类型,创建相应的图片
$img = @imagecreatefromjpeg($updir_file);
}elseif($ext == 'png'){
$img = @imagecreatefrompng($updir_file);
}elseif($ext=='gif'){
$img=imagecreatefromgif($updir_file);
}
list($RealWidth, $RealHeight) = getimagesize($img); //获取图片的宽高。
$shuoluetu=imagecreatetruecolor(100,100);//创建真彩图
imagecopyresized($shuoluetu,$img,0,0,0,0,100,100,$RealWidth,$RealHeight);//创建100*100的缩略图
-----------------------------------------------创建缩略图------------------------------------------------------------------------------------------------------------
7,表单JS验证
-------------------JS验证(此处定义一个函数放在JS文件中)---------------------------------------------------------
function check(){
if(document.form1.userid.value==""){
alert("请输入用户名!");
document.form1.userid.focus();
return false;
}
if(document.form1.userid.value.length10){
alert("用户名必须在5到10位之间!");
document.form1.userid.focus();
return false;
}
var m1=/[\u4e00-\u9fa5]/g;
if(!m1.test(document.form1.name.value)){
alert(姓名必须是中文!);
form1.name.value.focus();
return false;
}
}
在HTML中调用
--------------------------------------JS验证,一个对话框创建一个函数,-----------------------------------------------------------------------------
my_check.js---------------
function register_userid_check(){
var text1="document.form1.userid.value";
if(document.form1.userid.value==""){
document.getElementById('userid_c').innerHTML="用户名不能为空";
return false;
}
/*}else{
document.getElementById('userid_c').innerHTML="";
}*/
else if(document.form1.userid.value.length>10 || document.form1.userid.value.length=document.form1.userid.value.length)
{
document.getElementById('userid_c').innerHTML="√";
return true;
}
}
function register_password_check(){
if(document.form1.password.value==""){
document.getElementById('password_c').innerHTML="密码不能为空";
return false;
}else if(document.form1.password.value.length
----------------------------------------------------页面跳转-----------------------------------------------------------------------------
3< /a>秒后自动返回…
function countDown(secs){
tiao.innerText=secs;
if(--secs>0){
setTimeout("countDown("+secs+")",1000);
}else{
location.href="xx.html"//top.location.href=""//跳转到上级页面。
}
}
countDown(3);
-------------------------页面跳转---------------------------------------------------------------------------------
header("location:xx.html");//头信息跳转
javascript:history.back(1);//后退一步跳转
//meta跳转,content=2指暂停2秒再跳转
top.location='yy.html' //返回上一级页面再跳转
setTimeout(top.location='xx.php',50000);//用于在指定的毫秒数后调用函数或计算表达式。
location.href='register.php';//跳转
history.go(-1);//返回跳转
//body中加载跳转,top指先回到上一级页面再跳转。
页:
[1]