冲刺阶段——Day3

冲刺阶段——Day3

团队成员:20191202 王皓岩 20191209 徐嘉晟20191214 郭 昊 20191220 朱轩锐 20191227甘泞与 20191231 高泽正

时间:12月1日

团队成员今天任务

王皓岩 前端页面的逻辑跳转

高泽正 继续完善用户登录、注册前端界面

郭 昊 后端实现上传下载功能

徐嘉晟 开始制作登录注册数据库

甘泞与 开始设计后端架构

朱轩锐 协助实现后端

 

 

本日任务:前端页面的逻辑跳转

今日所完成代码链接:

 王皓岩/why1203 - Gitee.com

 

在登录注册页面,需要用到逻辑跳转

注册时的跳转:

 

$("#button").click(
        function(){
            if($("#sid2").val()=="您的账号")
            alert("请输入账号");
            else if($("#spassword2").val()=="您的密码")
            alert("请输入密码"); 
            else
$.post("set.php",{sid:$("#sid2").val(),
spassword:$("#spassword2").val()},function(data)
            {
                alert(data);
                });});
});

 

这里需要请求set.php

<?php
$myfile = fopen("person.txt", "a+") or die("Unable to open file!");
fclose($myfile);
$myfile = fopen("person.txt", "r") or die("Unable to open file!");
if(!preg_match("/^[a-zA-Z0-9]*$/",$_POST['sid'])||!preg_match("/^[0-9]*$/",$_POST['spassword']))
{
    echo "输入账号或密码的格式错误,账号只能是英文字母或数字的组合,密码只能是数字的组合";

    return;
    
    
    }
function gets($myfile)
{
    $num="";
    $num2="";
    while(1)
    {
        if(feof($myfile)||($num2=fgetc($myfile))=="&")
        {
            return $num;
            }
        $num=$num.$num2;
        
    }
    
    
}
if(!feof($myfile))
    fgetc($myfile);
    
while(!feof($myfile))
{
$num3=gets($myfile);
$num4=gets($myfile);
if($num3==$_POST['sid'])
{
    echo "账号与存在,请用其他账号";
    fclose($myfile);
    return ;
}
}
fclose($myfile);

$myfile = fopen("person.txt", "a+") or die("Unable to open file!");
fwrite($myfile,"&");
fwrite($myfile,$_POST['sid']);
fwrite($myfile,"&");
fwrite($myfile,$_POST['spassword']);

fclose($myfile);
mkdir("upload/".$_POST['sid']);
mkdir("upload/".$_POST['sid']."/send");
$myfile = fopen("upload/".$_POST['sid']."/send/sendingperson.txt","w");
fclose($myfile);

echo "注册成功!";
?>

在php文件中,会将账号与密码存于person.txt中,并与person.txt中所存账号进行比对,避免重复。

 

登录时的逻辑跳转

    $("#login").click(
        function(){
            if($("#sid").val()=="您的账号")
            alert("请输入账号");
            else if($("#spassword").val()=="您的密码")
            alert("请输入密码");
            else
            $.post("index.php",{sid:$("#sid").val(),spassword:$("#spassword").val()},
            function(data)
            {
                if(data==-1)
                alert("输入账号或密码的格式错误,账号只能是英文字母或数字的组合,密码只能是数字的组合");
                else if(data==-2)
                alert("输入的密码不正确或账号不存在");
                else
                {
                    var sname=eval('('+data+')');
                    var sidx=sname['sid'];
                    alert("登陆成功!");    
                    window.location.href="personal.html?sid="+sidx;
                    }
                
                
                }
            
            )
            
            
            }
        );

这里需要请求index.php

<?php
$myfile = fopen("person.txt", "a+") or die("Unable to open file!");
fclose($myfile);
$myfile = fopen("person.txt", "r") or die("Unable to open file!");
if(!preg_match("/^[a-zA-Z0-9]*$/",$_POST['sid'])||!preg_match("/^[0-9]*$/",$_POST['spassword']))
{
    echo "-1";
    return;
    
    
    }
function gets($myfile)
{
    $num="";
    $num2="";
    while(1)
    {
        if(feof($myfile)||($num2=fgetc($myfile))=="&")
        {
            return $num;
            }
        $num=$num.$num2;
        
    }
    
    
}
if(!feof($myfile))
    fgetc($myfile);
    
while(!feof($myfile))
{
$num3=gets($myfile);
$num4=gets($myfile);
if($num3==$_POST['sid']&&$num4==$_POST['spassword'])
{
    $data=array('boolean'=>'true','sid'=>$_POST['sid'],'spassword'=>$_POST['spassword']);
    $data=json_encode($data);
    echo $data;
    fclose($myfile);
        
    $myfile = fopen("getid.txt", "w") or die("Unable         to open file!");
    fwrite($myfile,$_POST['sid']);
    
    fclose($myfile);
    return ;
}
}

echo "-2";
fclose($myfile);

?>

账号和密码从person.txt中读取出来与输入的进行比对,若正确,则会跳转到person.html中

 

各个成员今日的任务量

王皓岩 6

高泽正 3

郭 昊 4

徐嘉晟 5

朱轩锐 4

甘泞与 3

各个成员今日对项目的贡献量

王皓岩 5

高泽正 4

郭 昊 3

徐嘉晟 4

朱轩锐 3

 甘泞与 4

 

 明日内容:

后端实现文件发送和下载

 

posted @ 2021-12-05 22:38  20191202王皓岩  阅读(55)  评论(0编辑  收藏  举报