par
iibeast » 28 janv. 2015, 20:56
Bonjour, je suis débutant en php, et j'ai voulu tester d'intégrer un système d'inscription à mon site en local.
Lors de l'envoi du formulaire, rien ne se passe ni sur la page, ni au niveau de la base de donnée. Je viens de passer en MySqli mais le problème était le même en MySql.
Si quelqu'un peut m'aider à trouver d'où cela peut venir ..
<?php
session_start();
include_once 'config.php';
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="register.css" />
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>Iibeast54 on Crystal</title>
<style type="text/css">
input[type=text]{
border:dotted 1px orange;
}
textarea{
border:dotted 1px orange;
width:880px;
height:200px;
}
input[type=submit]{
font-size:20px;
color:orange;
width:120px;
border:solid 1px orange;
border-radius:5px;
background:rgba(0, 0, 0, 0);
}
input[type=submit]:hover{
cursor:pointer;
}
.error-message{
font-style:italic;
color:red;
}
</style>
</head>
<!--[if IE 6 ]><body class="ie6 old_ie"><![endif]-->
<!--[if IE 7 ]><body class="ie7 old_ie"><![endif]-->
<!--[if IE 8 ]><body class="ie8"><![endif]-->
<!--[if IE 9 ]><body class="ie9"><![endif]-->
<!--[if !IE]><!--><body><!--<![endif]-->
<header>
<div id="main_title">
<h1><a href="index.php" title="Index">####</a></h1>
<h2><a href="#" title="#####" target="_blank"><strong>#####</strong></a></h2>
</div>
</header>
<nav>
<ul>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
</ul>
</nav>
<center><div id="block_principal">
Welcome to the register page. You will be able to register here by following this form.
</div></center>
<div id="block_intro">
<form method="POST" action="register.php">
<label for="username">Username :</label> <br />
<input type="text" name="username" id="username" /> <br />
<label for="pass1">Password :</label> <br />
<input type="text" name="password" id="password" /> <br />
<label for="pass2">Repeat it :</label> <br />
<input type="text" name="repeatpassword" id="repeatpassword" /> <br />
<center><input type="submit" value="Register" /> <br />
</center>
</form>
<?php
if(isset($_POST['submit'])) // Création des variable suite à l'appui sur le bouton.
{
$username = htmlentities(trim($_POST['username'])); // Sécurisation des variables.
$password = htmlentities(trim($_POST['password'])); //
$repeatpassword = htmlentities(trim($_POST['repeatpassword'])); //
if($username&&$password&&$repeatpassword) // Vérification des longueurs appropriées.
{
$login = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM users WHERE username='$username'");
$rows = mysqli_num_rows($login);
if($rows == 0)
{
if(strlen($username) > 4)
{
if(strlen($password) > 4)
{
if($password == $repeatpassword)
{
$password = md5($password);
$req = "INSERT INTO users(login,pass) VALUES('','$username','$password')";
$exec = mysqli_query($GLOBALS["___mysqli_ston"], $req);
echo "Successfully registered.";
header('Location:index.php');
}else echo "Same passwords please.";
}else echo "Password length too low.";
}else echo "Username length too low.";
}else echo "Username already used.";
}else echo "Anything is missing.";
}
?>
</div>
</body>
</html>
Et voici mon code de la config appelée dans la page ...
<?php
$connexion = ($GLOBALS["___mysqli_ston"] = mysqli_connect('localhost', 'root', ''));
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE test"));
((is_null($___mysqli_res = mysqli_close($connexion))) ? false : $___mysqli_res);
?>
En vous remerciant par avance,
iibeast
Bonjour, je suis débutant en php, et j'ai voulu tester d'intégrer un système d'inscription à mon site en local.
Lors de l'envoi du formulaire, rien ne se passe ni sur la page, ni au niveau de la base de donnée. Je viens de passer en MySqli mais le problème était le même en MySql.
Si quelqu'un peut m'aider à trouver d'où cela peut venir .. [php]<?php
session_start();
include_once 'config.php';
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="register.css" />
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>Iibeast54 on Crystal</title>
<style type="text/css">
input[type=text]{
border:dotted 1px orange;
}
textarea{
border:dotted 1px orange;
width:880px;
height:200px;
}
input[type=submit]{
font-size:20px;
color:orange;
width:120px;
border:solid 1px orange;
border-radius:5px;
background:rgba(0, 0, 0, 0);
}
input[type=submit]:hover{
cursor:pointer;
}
.error-message{
font-style:italic;
color:red;
}
</style>
</head>
<!--[if IE 6 ]><body class="ie6 old_ie"><![endif]-->
<!--[if IE 7 ]><body class="ie7 old_ie"><![endif]-->
<!--[if IE 8 ]><body class="ie8"><![endif]-->
<!--[if IE 9 ]><body class="ie9"><![endif]-->
<!--[if !IE]><!--><body><!--<![endif]-->
<header>
<div id="main_title">
<h1><a href="index.php" title="Index">####</a></h1>
<h2><a href="#" title="#####" target="_blank"><strong>#####</strong></a></h2>
</div>
</header>
<nav>
<ul>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
<li><a href="#" title="">#</a></li>
</ul>
</nav>
<center><div id="block_principal">
Welcome to the register page. You will be able to register here by following this form.
</div></center>
<div id="block_intro">
<form method="POST" action="register.php">
<label for="username">Username :</label> <br />
<input type="text" name="username" id="username" /> <br />
<label for="pass1">Password :</label> <br />
<input type="text" name="password" id="password" /> <br />
<label for="pass2">Repeat it :</label> <br />
<input type="text" name="repeatpassword" id="repeatpassword" /> <br />
<center><input type="submit" value="Register" /> <br />
</center>
</form>
<?php
if(isset($_POST['submit'])) // Création des variable suite à l'appui sur le bouton.
{
$username = htmlentities(trim($_POST['username'])); // Sécurisation des variables.
$password = htmlentities(trim($_POST['password'])); //
$repeatpassword = htmlentities(trim($_POST['repeatpassword'])); //
if($username&&$password&&$repeatpassword) // Vérification des longueurs appropriées.
{
$login = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM users WHERE username='$username'");
$rows = mysqli_num_rows($login);
if($rows == 0)
{
if(strlen($username) > 4)
{
if(strlen($password) > 4)
{
if($password == $repeatpassword)
{
$password = md5($password);
$req = "INSERT INTO users(login,pass) VALUES('','$username','$password')";
$exec = mysqli_query($GLOBALS["___mysqli_ston"], $req);
echo "Successfully registered.";
header('Location:index.php');
}else echo "Same passwords please.";
}else echo "Password length too low.";
}else echo "Username length too low.";
}else echo "Username already used.";
}else echo "Anything is missing.";
}
?>
</div>
</body>
</html>[/php]
Et voici mon code de la config appelée dans la page ...
[php]<?php
$connexion = ($GLOBALS["___mysqli_ston"] = mysqli_connect('localhost', 'root', ''));
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE test"));
((is_null($___mysqli_res = mysqli_close($connexion))) ? false : $___mysqli_res);
?>[/php]
En vous remerciant par avance,
iibeast