帮我看看下面的代码怎么不执行form表单

sssschenyi 2015-08-19 12:29:47
<?php
/*注册文件
* $Author: 陈义
* $Id: regist.php 2013-12-17 21:07 陈义
*/
//检查session是否存在。
include('check_session.php');
include('head.php');
if(isset($_SESSION['id']) &&isset($_SESSION['pass'])){
// if(isset($_SESSION['id'])==true &&isset($_SESSION['pass'])==true){
exit("当前已有一个登陆在线的用户<span class=online_user>".$_SESSION['id']."</span>需要再<a href=regist.php>注册</a>请先<a href=index.php?act=out>退出。</a>否则请<a href=javascript: onclick=history.go(-1);>返回</a>");
}

define('cy','cychat');
include('config.php');

$name=isset($_POST['name']) ? $_POST['name']:null;
$password=isset($_POST['password']) ? $_POST['password']:null;
$addess=isset($_POST['addess']) ? $_POST['addess']:null;
$age=isset($_POST['age']) ? $_POST['age']:null;
$name_md5=md5($name);//给用户名add 一个 md5值

////////////////接收用户上传的头像文件///////////////////////////
error_reporting(0);
$upfilepath="image/userimage/";
$file_houzhui='';
if($_FILES["userimage"]["type"] == "image/gif"){
$file_houzhui=".gif";
}

if($_FILES["userimage"]["type"] == "image/jpeg"){
$file_houzhui=".jpg";
}

if($_FILES["userimage"]["type"] == "image/png"){
$file_houzhui=".png";
}

switch ($_FILES["userimage"]["error"])
{
case 1:
echo "上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值";
break;
case 2:
echo "上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值";
break;
case 3:
echo "文件只有部分被上传.";
break;
case 4:
echo "你没有上传图像。";
break;
case 6:
echo "找不到临时文件夹.";
break;
case 7:
echo "文件写入失败.";
break;
}

move_uploaded_file($_FILES["userimage"]["tmp_name"],$upfilepath.$_FILES["userimage"]["name"]);//从server 移动用户上传文件到新的路径
rename($upfilepath.$_FILES["userimage"]["name"] ,$upfilepath.'tmp'.$name.$file_houzhui);//将客户上传的文件更名为一个临时的文件

$source_filename=$upfilepath.'tmp'.$name.$file_houzhui;

///////////////////////调整用户上传的图片大小///////////////

$filetype=mime_content_type($source_filename);//获取图片的类型。mime_content_type 函数要在php.ini打开 fileinfo选项
//echo 'the file type is'.$filetype;
list($width, $height) = getimagesize($source_filename);//获取原图片的大小

//如果文件的宽度和高度都小于120就把临时文件改名为正式的文件,
if($width <= 120 && $height <= 120){
rename($upfilepath.'tmp'.$name.$file_houzhui,$upfilepath.$name.$file_houzhui);
}


//判断图片的width and height 大于120 就缩小为 120*120 的新图片
if($width > 120 || $heitht > 120){
$new_width = 120;
$new_height = 120;
$image_p = imagecreatetruecolor($new_width, $new_height);// 新建一个真色彩的文件
//// 重新取样,新建一个和用户上传同类型的文件
//判断用户上传的是那种类型图片
if($filetype == "image/gif"){
$image = imagecreatefromgif($source_filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);//copy 源图像到新建的真色彩文件。
imagegif($image_p,$upfilepath.$name.$file_houzhui);//保存图片到新地址,并且重新更名
}
//判断用户上传的是那种类型图片
if($filetype == "image/jpeg"){
$image = imagecreatefromjpeg($source_filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);//copy 源图像到新建的真色彩文件。
imagejpeg($image_p,$upfilepath.$name.$file_houzhui, 80);//保存图片到新地址,并且重新更名
}
//判断用户上传的是那种类型图片
if($filetype == "image/png"){
$image = imagecreatefrompng($source_filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);//copy 源图像到新建的真色彩文件。
imagepng($image_p,$upfilepath.$name.$file_houzhui);//保存图片到新地址,并且重新更名
}

imagedestroy ($image);//销毁图片占用的内存
imagedestroy ($image_p);//销毁图片占用的内存
unlink($source_filename);//del 用户上传的原图片,这行很重要!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
//*//////////////////////////////////////$\
$useruploadimageaddess="";//用于插入数据库的变量

//如果上传的不是图像文件或者没有上传文件
if($filetype != "image/png" && $filetype != "image/gif" && $filetype != "image/jpeg"){
$useruploadimageaddess='noaddess';
}else{
$useruploadimageaddess=$upfilepath.$name.$file_houzhui;//用于插入数据库的变量
}
///////////////////////////////////////////////////////
$sql = "INSERT INTO user( `user`,user_md5, `password`, `addess`, `age`,`userImage`,`regist_date`) VALUES ('$name','$name_md5','$password','$addess',$age,'$useruploadimageaddess',now())";


/////////////////////////////
/////////////////////////////
//检查是否有用户已经注册
$inquiry_username = mysql_query("SELECT user FROM user WHERE user='$name'");
if(mysql_num_rows($inquiry_username)>=1){
exit(' 对不起!!!<strong style=color:red>'.$name.'</strong>用户已经有人注册。');
}
//
if($name!=null && $password!=null && $addess!=null && $age!=null){
if(mysql_query($sql,$linkdatabase)){
exit("<p style=color:red><b>您已成功注册。请记住您的用户名和密码!用户名是$name 密码是$password 请<a href=\"login.php\">登录</a></p>");//如果注册成功就不输出下面的表单。
}else{
echo '注册失败,请重新注册';
}
}

echo '<div class="regist">
<form method="post" enctype="multipart/form-data" action="regist.php">
<label for="name">用户名:</label>
<input class="regist_username" type="text" name="name" /> *<br/>
<label for="password">密  码:</label>
<input class="regist_password" type="password" name="password"/> *<br/>
<label for="addess">地  址:</label>
<input class="regist_addess"type="text" name="addess"/> *<br/>
<label for="age">年  龄:</label>
<input class="regist_age" type="text" name="age"/> *<br/>
<label for="userimage">头  像:</label>
<input type="file" name="userimage" value="userimage"><br/>
<input class="regist_regist" type="submit" value="注册"><br/>
<label for="info">带'*'号的必须要填写信息 </label>
</form>
</div>';


include "footpage.php";//页脚
?>
...全文
174 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sssschenyi 2015-08-19
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
那你的页面显示了什么?
就显示了include('head.php'); form表单没有出来
xuzuning 2015-08-19
  • 打赏
  • 举报
回复
那你的页面显示了什么?
彬莫 2015-08-19
  • 打赏
  • 举报
回复
<label for="info">带'*'号的必须要填写信息 </label> 把* 的单引去掉

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧