本当場合:表示/非表示PHPの変数は、それがこれは私のhtmlコードである
<div id="view" class="login-box animated fadeInUp"<?php if ($reg===true){?>style="display:none"<?php } ?>>
</div>
<div id="popup"<?php if ($reg===false){?>style="display:none"<?php } ?>>
</div>
これは私のPHPコードの一部です:
<?php
ob_start();
session_start();
error_reporting(~E_DEPRECATED & ~E_NOTICE);
$conn = mysqli_connect('localhost','root','','slide-uploader');
if (!$conn) {
die("Connection failed : " . mysqli_connect_error());
}
$error = false;
$reg = false;
/*Verifico i campi della form*/
if (isset($_POST['submit'])) {
$email = trim($_POST['user_email']);
$email = strip_tags($email);
$email = htmlspecialchars($email);
$mailValidation = explode('@',$email)[1];
$matricola = trim($_POST['user_matricola']);
$name = ucfirst(explode('.',$email)[0]);
$surname = ucfirst(preg_replace('/[0-9]+/', '', explode('@',explode('.',$email)[1]))[0]);
$queryS = "SELECT * FROM studente WHERE Matricola ='$matricola'";
$resS = mysqli_query($conn,$queryS);
$count = mysqli_num_rows($resS);
if($count<1){
$query = "INSERT INTO studente (Matricola, Nome, Cognome, User) VALUES('$matricola','$name','$surname','$email')";
$res = mysqli_query($conn,$query);
}else{
some code...
}
if ($res) {
some code...
unset($email);
$reg = true;
some code...
} else {
some code...
}
}
}
ob_end_flush();
?>
私は、ユーザーがログインしてから復帰(window.history.go (-1)
)、$reg
は設定されていないようです。
私はhtmlページで$ reg変数を設定する必要がありますか? htmlページとphpページは2つの別々のファイルです。
変数$ _SESSION
を使用する必要がありますか?
trueの場合?'あなたは.htmlのファイルを意味するのですか? PHPはhtmlファイルでは実行できません。 – Andreas
@Andreas実際にPHPを.html-filesとして解析するようにサーバを設定することは可能です。しかし、それはお勧めしません。 – StuntHacks
あなたのコードはSQLインジェクションに対して脆弱です。これを修正する必要があります。 – Enstage