2017-12-19 8 views
-2

mysql을 사용하여 로그인 폼 유효성 검사를하는 방법은 많이 있지만 PHP로 간단한 폼 유효성 검사를하려고합니다. 나는이 오류 받고 있어요 :PHP로 간단한 폼 유효성 검사 - 로그인 화면

<?php 
 

 

 

 
$usuario = $_POST['usuario']; 
 
$senha = $_POST['senha']; 
 

 

 

 
if(($usuario=='marketing') && ($senha=='onecia40012121') { 
 
    echo header('Location: http://www.onecia.com.br/ato/?lead=ok'); THIS LINE HAVE A PROBLEM 
 
} else { 
 
    echo "<script>alert('Login ou senha incorretos!');</script>"; 
 
} 
 

 

 

 
?>
: 그리고, 가장 중요한, 여기 내 PHP 파일이

body { 
 
    font-family: "Open Sans", sans-serif; 
 
    height: 100vh; 
 
    background: url("https://i.imgur.com/HgflTDf.jpg") 50% fixed; 
 
    background-size: cover; 
 
} 
 

 
@keyframes spinner { 
 
    0% { 
 
    transform: rotateZ(0deg); 
 
    } 
 
    100% { 
 
    transform: rotateZ(359deg); 
 
    } 
 
} 
 
* { 
 
    box-sizing: border-box; 
 
} 
 

 
.wrapper { 
 
    display: flex; 
 
    align-items: center; 
 
    flex-direction: column; 
 
    justify-content: center; 
 
    width: 100%; 
 
    min-height: 100%; 
 
    padding: 20px; 
 
    background: rgba(4, 40, 68, 0.85); 
 
} 
 

 
.login { 
 
    border-radius: 2px 2px 5px 5px; 
 
    padding: 10px 20px 20px 20px; 
 
    width: 90%; 
 
    max-width: 320px; 
 
    background: #ffffff; 
 
    position: relative; 
 
    padding-bottom: 80px; 
 
    box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.3); 
 
} 
 
.login.loading button { 
 
    max-height: 100%; 
 
    padding-top: 50px; 
 
} 
 
.login.loading button .spinner { 
 
    opacity: 1; 
 
    top: 40%; 
 
} 
 
.login.ok button { 
 
    background-color: #8bc34a; 
 
} 
 
.login.ok button .spinner { 
 
    border-radius: 0; 
 
    border-top-color: transparent; 
 
    border-right-color: transparent; 
 
    height: 20px; 
 
    animation: none; 
 
    transform: rotateZ(-45deg); 
 
} 
 
.login input { 
 
    display: block; 
 
    padding: 15px 10px; 
 
    margin-bottom: 10px; 
 
    width: 100%; 
 
    border: 1px solid #ddd; 
 
    transition: border-width 0.2s ease; 
 
    border-radius: 2px; 
 
    color: #ccc; 
 
} 
 
.login input + i.fa { 
 
    color: #fff; 
 
    font-size: 1em; 
 
    position: absolute; 
 
    margin-top: -47px; 
 
    opacity: 0; 
 
    left: 0; 
 
    transition: all 0.1s ease-in; 
 
} 
 
.login input:focus { 
 
    outline: none; 
 
    color: #444; 
 
    border-color: #2196F3; 
 
    border-left-width: 35px; 
 
} 
 
.login input:focus + i.fa { 
 
    opacity: 1; 
 
    left: 30px; 
 
    transition: all 0.25s ease-out; 
 
} 
 
.login a { 
 
    font-size: 0.8em; 
 
    color: #2196F3; 
 
    text-decoration: none; 
 
} 
 
.login .title { 
 
    color: #444; 
 
    font-size: 1.2em; 
 
    font-weight: bold; 
 
    margin: 10px 0 30px 0; 
 
    border-bottom: 1px solid #eee; 
 
    padding-bottom: 20px; 
 
} 
 
.login button { 
 
    width: 100%; 
 
    height: 100%; 
 
    padding: 10px 10px; 
 
    background: #2196F3; 
 
    color: #fff; 
 
    display: block; 
 
    border: none; 
 
    margin-top: 20px; 
 
    position: absolute; 
 
    left: 0; 
 
    bottom: 0; 
 
    max-height: 60px; 
 
    border: 0px solid rgba(0, 0, 0, 0.1); 
 
    border-radius: 0 0 2px 2px; 
 
    transform: rotateZ(0deg); 
 
    transition: all 0.1s ease-out; 
 
    border-bottom-width: 7px; 
 
} 
 
.login button .spinner { 
 
    display: block; 
 
    width: 40px; 
 
    height: 40px; 
 
    position: absolute; 
 
    border: 4px solid #ffffff; 
 
    border-top-color: rgba(255, 255, 255, 0.3); 
 
    border-radius: 100%; 
 
    left: 50%; 
 
    top: 0; 
 
    opacity: 0; 
 
    margin-left: -20px; 
 
    margin-top: -20px; 
 
    animation: spinner 0.6s infinite linear; 
 
    transition: top 0.3s 0.3s ease, opacity 0.3s 0.3s ease, border-radius 0.3s ease; 
 
    box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.2); 
 
} 
 
.login:not(.loading) button:hover { 
 
    box-shadow: 0px 1px 3px #2196F3; 
 
} 
 
.login:not(.loading) button:focus { 
 
    border-bottom-width: 4px; 
 
} 
 

 
footer { 
 
    display: block; 
 
    padding-top: 50px; 
 
    text-align: center; 
 
    color: #ddd; 
 
    font-weight: normal; 
 
    text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2); 
 
    font-size: 0.8em; 
 
} 
 
footer a, footer a:link { 
 
    color: #fff; 
 
    text-decoration: none; 
 
}
<!DOCTYPE html> 
 
<html lang="en" > 
 
<head> 
 
    <meta charset="UTF-8"> 
 
    <title>Calendário de E-mail marketing</title> 
 
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'> 
 
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> 
 
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> 
 

 
    
 
    
 

 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script> 
 

 
</head> 
 

 
<body> 
 
    <div class="wrapper"> 
 
    <form class="login" action="valida.php" method="post"> 
 
    <p class="title">Log in</p> 
 
    <input id="usuario" class="usuario" type="text" placeholder="Usuário" autofocus/> 
 
    <i class="fa fa-user"></i> 
 
    <input id="senha" clas="senha" type="password" placeholder="Senha" /> 
 
    <i class="fa fa-key"></i> 
 

 
    <button> 
 
     <i class="spinner"></i> 
 
     <span class="state">Log in</span> 
 
    </button> 
 
    </form> 
 
    <footer>2017 One Imóveis de Luxo</footer> 
 
    </p> 
 
</div> 
 
    <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> 
 

 
    
 

 
</body> 
 
</html>

입니다 : 여기

Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\xampp2\htdocs\one\homedir\public_html\calendario\valida.php on line 11

것이 내 양식이다

도움을 받으실 때까지 기다려주세요.

+0

'if'에서')'가 누락되었습니다. – FirstOne

+0

if 문 – pravindot17

+0

''php -l C : \ xampp2 \ htdocs \ one \ homedir \ public_html \ calendario \ valida.php'의 닫는 둥근')'대괄호가 파일의 구문 오류를 알려줍니다. – alistaircol

답변

0

if 문에 )가 누락되었습니다. 코드에 항상 ()으로 사용하십시오.

<?php 

$usuario = $_POST['usuario']; 
$senha = $_POST['senha']; 

if(($usuario=='######') && ($senha=='######')) { 
    echo header('Location: http://www.example.com.br/ato/?lead=ok'); 
} else { 
    echo "<script>alert('Login ou senha incorretos!');</script>"; 
} 

?> 

아, 질문에서 사용자 이름, 비밀번호 및 사이트 URL을 삭제하는 것이 좋습니다.

+1

@AgeDeo '이 줄에는 문제가있다'고 대답해야한다 – pravindot17

+0

네가 어디에서 옳은지, 내가 질문에서 복사했는지, 바꿨다. – AgeDeO

+0

이 질문은 아마도 간단한 인쇄상의 오류로 표시 될 수 있습니다. – FirstOne