[php] Besoin d'aide code "résolu"
Posté : 28 janv. 2008, 13:52
Bonjours voila j'ai prit ce code sur internet pour cree un page d'enregistrement mon probleme est que :
quant je le met sur mon site apres avoir traduit des phrases en francais "du style: le compte a ete cree"
il me met une erreur ligne 21 ou yas ma traction merci de m'aidez
2eme j'ai cree un hyperlien vers une autre page du forum du style: totoleding.ifrance.com/forum
et lui me marque l'adresse su site actuel + le lien donc ca donne ca
totoleding.ifrance.com/reg/totoleding.ifrance.com/forum
Donc c'est tres genant si une personne pouvait m'aidez et m'expliquer car je suis debutant ce serait sympa
voila le code php:
$tbc = '8'; // For enabling TBC. Don't edit.
error_reporting(E_ALL ^ E_NOTICE);
session_start();
$msg = Array();
$error = Array();
function addUser(){
if (empty($_POST)) return false;
global $config, $msg, $error;
if (empty($_POST['login'])) $error[] = 'Erreur, vous avez oublier d'entrer un nom d'utilisateur! ';
if (empty($_POST['password'][0]) || empty($_POST['password'][1])) $error[] = 'Erreur, vous avez oubliez d'entrer un password! ';
if ($_POST['password'][0] !== $_POST['password'][1]) $error[] = 'Les passwords ne sont pas les memes !!! ';
if (!empty($error)) return false;
$db = @mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_pass']);
if (!$db) return $error[] = 'Database: '.mysql_error();
if (!@mysql_select_db($config['mysql_dbname'], $db)) return $error[] = 'Database: '.mysql_error();
$query = "SELECT `acct` FROM `accounts` WHERE `login` = '".mysql_real_escape_string($_POST['login'])."'";
$res = mysql_query($query, $db);
if (!$res) return $error[] = 'Database: '.mysql_error();
if (mysql_num_rows($res) > 0) return $error[] = 'Le nom de compte existe déjà ';
if ($_POST['flags'] == 1){$tbc = "8";} else {$tbc = "0";} // Enables TBC
$query = "INSERT INTO `accounts` (`login`,`password`,`lastip`,`flags`) VALUES ('".mysql_real_escape_string($_POST['login'])."', '".mysql_real_escape_string($_POST['password'][0])."', '".$_SERVER['REMOTE_ADDR']."', 8)";
$res = mysql_query($query, $db);
if (!$res) return $error[] = 'Database: '.mysql_error();
$msg[] = 'Le compte <strong>'.htmlentities($_POST['login']).'</strong> a bien été crée, vous pouvait maintenant vous connecter sur le serveur de jeux TetraByte!!! ';
mysql_close($db);
return true;
}
{
addUser();
}
?>
<html>
<head>
<title>Création de compte</title>
<style>
body, table {
font-family: Verdana;
font-size: 13px;
background-color: #000000;
color: #FF9900
}
input {
font-family: Tahoma;
text-align: center;
padding: 2px;
}
input.button {
font-family: Verdana;
font-size: 12px;
padding: 2px 25px;
}
div.error {
border: 2px solid #FF0000;
background-color: #f48987;
padding: 4px;
}
div.msg {
background-color: #9fd5b5;
padding: 4px;
border: 2px solid #CC0000;
}
.Style1 {color: #009900}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<u>
<h2 align="left">
<center><img src=img/logo.png></center></h2></u>
<?php
if (!empty($error)){
echo '<div class="error">';
foreach($error as $text)
echo $text.'<br/>';
echo '</div>';
};
if (!empty($msg)){
echo '<div class="msg">';
foreach($msg as $text)
echo $text.'<br/>';
echo '</div>';
exit('</body></html>');
};
?>
<center><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table><div align="center"><br>
<b style = "color:orange; font-size:8pt; font-variant: small-caps; letter-spacing:3px;"><i>N</i>om du <i>C</i>ompte:</b><br>
<input type="text" name="login" size="30" maxlength="16"/>
<br>
<b style = "color:orange; font-size:8pt; font-variant: small-caps; letter-spacing:3px;"><i>M</i>ot de <i>P</i>asse:</b><br>
<input type="password" name="password[]" size="30" maxlength="16"/>
<br>
<b style = "color:orange; font-size:8pt; font-variant: small-caps; letter-spacing:3px;"><i>R</i>etaper <i>M</i>ot de <i>P</i>asse:</b><br>
<input type="password" name="password[]" size="30" maxlength="16"/>
<br>
<b style = "color:orange; font-size:8pt; font-variant: small-caps; letter-spacing:3px;"><i>TBC</i> Actif?</b> <input type="checkbox" name="flags" value="8" checked>
<br><br>
<input type="image" src="./create_fr.gif" value="Submit" alt="Submit">
</table>
<div align="center">
<p align="center" id="done" style="width: 220px; font-weight: bold; color: #29b503; font-family: tahoma, arial, sans; font-size: 13px;">
<span class="Style1">Realmlist:<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<!-- @page { size: 21cm 29.7cm; margin: 2cm } P { margin-bottom: 0.21cm } -->
set realmlist TetraByte.no-ip.org </span>
<p align="center" style="width: 220px; font-weight: bold; color: #009900; font-family: tahoma, arial, sans; font-size: 13px;"><br />
World Of Warcraft:
<p align="center" style="width: 220px; font-weight: bold; color: #009900; font-family: tahoma, arial, sans; font-size: 13px;"> Burning Croisade
<blockquote>
<blockquote>
<p><span style="color: #009900"><strong>Version 2.3.3 <br />
<br />
[<a href="totoleding.ifrance.com/forum">Forum</a>]
[<a href="totoleding.ifrance.com/stats">Statu</a>]</strong></span><br />
<br />
</p>
</blockquote>
</blockquote>
</div>
</form>
</body>
</html>
quant je le met sur mon site apres avoir traduit des phrases en francais "du style: le compte a ete cree"
il me met une erreur ligne 21 ou yas ma traction merci de m'aidez
2eme j'ai cree un hyperlien vers une autre page du forum du style: totoleding.ifrance.com/forum
et lui me marque l'adresse su site actuel + le lien donc ca donne ca
totoleding.ifrance.com/reg/totoleding.ifrance.com/forum
Donc c'est tres genant si une personne pouvait m'aidez et m'expliquer car je suis debutant ce serait sympa
voila le code php:
$tbc = '8'; // For enabling TBC. Don't edit.
error_reporting(E_ALL ^ E_NOTICE);
session_start();
$msg = Array();
$error = Array();
function addUser(){
if (empty($_POST)) return false;
global $config, $msg, $error;
if (empty($_POST['login'])) $error[] = 'Erreur, vous avez oublier d'entrer un nom d'utilisateur! ';
if (empty($_POST['password'][0]) || empty($_POST['password'][1])) $error[] = 'Erreur, vous avez oubliez d'entrer un password! ';
if ($_POST['password'][0] !== $_POST['password'][1]) $error[] = 'Les passwords ne sont pas les memes !!! ';
if (!empty($error)) return false;
$db = @mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_pass']);
if (!$db) return $error[] = 'Database: '.mysql_error();
if (!@mysql_select_db($config['mysql_dbname'], $db)) return $error[] = 'Database: '.mysql_error();
$query = "SELECT `acct` FROM `accounts` WHERE `login` = '".mysql_real_escape_string($_POST['login'])."'";
$res = mysql_query($query, $db);
if (!$res) return $error[] = 'Database: '.mysql_error();
if (mysql_num_rows($res) > 0) return $error[] = 'Le nom de compte existe déjà ';
if ($_POST['flags'] == 1){$tbc = "8";} else {$tbc = "0";} // Enables TBC
$query = "INSERT INTO `accounts` (`login`,`password`,`lastip`,`flags`) VALUES ('".mysql_real_escape_string($_POST['login'])."', '".mysql_real_escape_string($_POST['password'][0])."', '".$_SERVER['REMOTE_ADDR']."', 8)";
$res = mysql_query($query, $db);
if (!$res) return $error[] = 'Database: '.mysql_error();
$msg[] = 'Le compte <strong>'.htmlentities($_POST['login']).'</strong> a bien été crée, vous pouvait maintenant vous connecter sur le serveur de jeux TetraByte!!! ';
mysql_close($db);
return true;
}
{
addUser();
}
?>
<html>
<head>
<title>Création de compte</title>
<style>
body, table {
font-family: Verdana;
font-size: 13px;
background-color: #000000;
color: #FF9900
}
input {
font-family: Tahoma;
text-align: center;
padding: 2px;
}
input.button {
font-family: Verdana;
font-size: 12px;
padding: 2px 25px;
}
div.error {
border: 2px solid #FF0000;
background-color: #f48987;
padding: 4px;
}
div.msg {
background-color: #9fd5b5;
padding: 4px;
border: 2px solid #CC0000;
}
.Style1 {color: #009900}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<u>
<h2 align="left">
<center><img src=img/logo.png></center></h2></u>
<?php
if (!empty($error)){
echo '<div class="error">';
foreach($error as $text)
echo $text.'<br/>';
echo '</div>';
};
if (!empty($msg)){
echo '<div class="msg">';
foreach($msg as $text)
echo $text.'<br/>';
echo '</div>';
exit('</body></html>');
};
?>
<center><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table><div align="center"><br>
<b style = "color:orange; font-size:8pt; font-variant: small-caps; letter-spacing:3px;"><i>N</i>om du <i>C</i>ompte:</b><br>
<input type="text" name="login" size="30" maxlength="16"/>
<br>
<b style = "color:orange; font-size:8pt; font-variant: small-caps; letter-spacing:3px;"><i>M</i>ot de <i>P</i>asse:</b><br>
<input type="password" name="password[]" size="30" maxlength="16"/>
<br>
<b style = "color:orange; font-size:8pt; font-variant: small-caps; letter-spacing:3px;"><i>R</i>etaper <i>M</i>ot de <i>P</i>asse:</b><br>
<input type="password" name="password[]" size="30" maxlength="16"/>
<br>
<b style = "color:orange; font-size:8pt; font-variant: small-caps; letter-spacing:3px;"><i>TBC</i> Actif?</b> <input type="checkbox" name="flags" value="8" checked>
<br><br>
<input type="image" src="./create_fr.gif" value="Submit" alt="Submit">
</table>
<div align="center">
<p align="center" id="done" style="width: 220px; font-weight: bold; color: #29b503; font-family: tahoma, arial, sans; font-size: 13px;">
<span class="Style1">Realmlist:<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<!-- @page { size: 21cm 29.7cm; margin: 2cm } P { margin-bottom: 0.21cm } -->
set realmlist TetraByte.no-ip.org </span>
<p align="center" style="width: 220px; font-weight: bold; color: #009900; font-family: tahoma, arial, sans; font-size: 13px;"><br />
World Of Warcraft:
<p align="center" style="width: 220px; font-weight: bold; color: #009900; font-family: tahoma, arial, sans; font-size: 13px;"> Burning Croisade
<blockquote>
<blockquote>
<p><span style="color: #009900"><strong>Version 2.3.3 <br />
<br />
[<a href="totoleding.ifrance.com/forum">Forum</a>]
[<a href="totoleding.ifrance.com/stats">Statu</a>]</strong></span><br />
<br />
</p>
</blockquote>
</blockquote>
</div>
</form>
</body>
</html>