[MySQL] Protection site internet
Bonjour !
Peut-être une question souvent traitée ici ? Je vous expose mon pb
je cherche à protéger l'accès de ma page perso par un mot de passe.
1°) j'ai créé un fichier connect.php avec les codes de mySQL
qui comporte 2 champs : "user" et "motpasse"
Code:
1 2 3 4 5 6 7 8 9
|
<?php
$host_db = "sql.free.fr";
$user_db = "ItsMe";
$password_db = "myPW";
$bdd_db = "identi";
?> |
2°) j'ai créé un formulaire :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
<?php
// connexion à la base
include("connect.php");
if (isset($_POST['user'])){ $menu1=$_POST['user'];}
if (isset($_POST['motpasse'])){ $menu2=$_POST['motpasse'];}
?>
<p>
<?
$nombre=1;
if (isset($menu1)){$select_ref= mysql_query("SELECT * FROM identi WHERE user = '$menu1' AND motpasse = '$menu2'"); }
$nombre= mysql_affected_rows();
if ($nombre != 1) { ?>
<table>
<tr>
<td> Vous vous êtes trompés </td><td></td></td>
<td><? echo "identifiant ou mot de pase incorrect" ; ?> </td>
<td></td>
</tr>
<tr>
<td> </td>
<td><? ?> </td>
<td></td>
</tr>
<div align="center"><center>
<p align="left">
<table border="0" width="100%">
<tr>
<td><font
color="#009C80" size="2"
face="Verdana, Arial, Helvetica, sans-serif"><b><i><a href="test.php" title="retour" target="_self">Cliquez ici pour vous identifier à nouveau</a></i></b></font></td>
</tr>
</table>
</center></div>
<? } ?>
<? while($lignesoeuvr = mysql_fetch_array($select_ref)) {
if (($lignesoeuvr['user'] == $menu1) and ($lignesoeuvr['motpasse'] == $menu2)) {
?>
<td>
<div align="center"> </div>
<? } }
// on ferme la connexion à mysql
mysql_close();
?>
</body> |
Mais j'obtiens des codes d'erreur :
A link to the server could not be established
ce qui signifie je pense que l'accès à ma base SQL est impossible ?
Comment faire ?