Problem with authentication in php script
Hi!
I'm redoing a website for a friend and I have to deal with the php scripts already in place and done by somebody a bit like me : who can read and understand php, but not good enough to design something by himself and takes things from different places and put them together to make what he wants.
I have two things that are more or less working, but buggy.
I'm posting here the authentication problem, I'll open a new thread for the other problem as it has nothing to do with authentication.
Basically, here is the thing : a user can register and put his information to be stored in the database.
Registration is fine (inscriptionillu.php), information is collected in the DB like it should, but then, it doesn't return the confirmation page (traitementillu.php).
If a user is already registered, when he tries to connect, on first try he'll get a blank page (like after registration). If he tries again, he'll get the confirmation page alright.
I suspect there might be a session problem, or a problem in the if else statement, but I can't figure out why it's not working.
Those two pages are called inside a third page, with a <? session_start();?> on top of it. Connexion to the database is fine as well. Pathways to the different scripts are fine too.
Here they are :
inscriptionillu.php :
PHP Code:
<?
$met=$_POST["met"];
if ($met=="change")
{
include("connexion.php");
@mysql_connect($host,$user,$pass)
or die("Impossible de se connecter");
@mysql_select_db("$bdd")
or die("Impossible de se connecter");
$table="illustrateurs2";
$id=$_SESSION['id'];
$query = "SELECT * FROM $table WHERE ref='$id'";
$result = mysql_query($query);
$val = mysql_fetch_array($result);
$nom=$val['nom'];
$prenom=$val['prenom'];
$mdp=$val['mdp'];
$pseudo=$val['pseudo'];
$site=$val['site'];
$mail=$val['mail'];
$tel=$val['tel'];
$adresse=$val['adresse'];
$adresse2=$val['adresse2'];
$ville=$val['ville'];
$code=$val['code'];
$pays=$val['pays'];
$jour=$val['jour'];
$mois=$val['mois'];
$annee=$val['annee'];
$noto=$val['noto'];
}
?>
<h2 class="titre">Inscription</h2>
<br />
<div align="center">
<form name="formname" method="post" action="formillu.php?page=formulaire/traitementillu.php">
<br />
<span style="red">(*) champs
obligatoires</span>
<table border="0">
<tbody>
<tr>
<td align="right"> Nom : </td>
<td width="350" align="left"> <input size="30" maxlength="40" name="nom" type="area" <? if ($met=="change") echo "value='".$nom."'"; ?> ><span style="red">*</span>
</td>
</tr>
<tr>
<td align="right"> Prénom : </td>
<td align="left"> <input size="30" maxlength="20" name="prenom" type="area" <? if ($met=="change") echo "value='".$prenom."'"; ?> ><span style="red">*</span>
</td>
</tr>
<tr>
<td align="right"> Email : </td>
<td align="left"> <input size="40" name="mail" type="area" <? if ($met=="change") echo "value='".$mail."'"; ?> ><span style="red">*</span>
</td>
</tr>
<tr>
<td align="right"> Mot de Passe : </td>
<td align="left"> <input size="20" name="password" type="password" <? if ($met=="change") echo "value='".$mdp."'"; ?> ><span style="red">*</span>
</td>
</tr>
<tr>
<td align="right"> Adresse : </td>
<td align="left"> <input size="40" name="adresse1" type="area" <? if ($met=="change") echo "value='".$adresse."'"; ?> ><span style="red">*</span>
</td>
</tr>
<tr>
<td align="right"> Adresse : </td>
<td align="left"> <input size="40" name="adresse2" type="area" v <? if ($met=="change") echo "value='".$adresse2."'"; ?> >
</td>
</tr>
<tr>
<td align="right"> Code Postal : </td>
<td align="left"> <input size="8" name="codepostal" type="area" <? if ($met=="change") echo "value='".$code."'"; ?> ><span style="red">*</span>
</td>
</tr>
<tr>
<td align="right"> Ville : </td>
<td align="left"> <input size="30" name="ville" type="area" <? if ($met=="change") echo "value='".$ville."'"; ?> ><span style="red">*</span>
</td>
</tr>
<tr>
<td align="right"> Pays : </td>
<td align="left"> <input size="10" name="pays" type="area" <? if ($met=="change") echo "value='".$pays."'"; ?> ><span style="red">*</span>
</td>
</tr>
<tr>
<td align="right"> Téléphone : </td>
<td align="left"> <input size="20" name="tel" type="area" <? if ($met=="change") echo "value='".$tel."'"; ?> >
</td>
</tr>
<tr>
<td align="right"> Date de naissance : </td>
<td align="left"> <input size="1" name="jour" maxlength="2" type="text" <? if ($met=="change") echo "value='".$jour."'"; ?> > / <input size="1" name="mois" maxlength="2" type="area" <? if ($met=="change") echo "value='".$mois."'"; ?> > / <input size="3" name="annee" maxlength="4" type="text" <? if ($met=="change") echo "value='".$annee."'"; ?>> JJ/MM/AAAA
</td>
</tr>
<tr>
<td align="right"> Comment avez-vous connu <br />***** ? </td>
<td align="left"> <input size="40" name="noto" type="area" <? if ($met=="change") echo "value='".$noto."'"; ?> ><span style="red">*</span>
</td>
</tr>
<tr>
<td align="right"> Votre pseudo sur le forum : </td>
<td align="left"> <input size="20" name="pseudo" type="area" <? if ($met=="change") echo "value='".$pseudo."'"; ?> >
</td>
</tr>
<tr>
<td align="right"> Votre site internet : </td>
<td align="left"> <input size="20" name="site" type="area" <? if ($met=="change") echo "value='".$site."'"; ?> >
</td>
</tr
></tbody>
</table>
<br />
<input name="type" type="hidden" value="2">
<?
if ($met=="change")
{
echo '<input name="new" type="hidden" value="no">';
}
else
{
echo '<input name="new" type="hidden" value="yes">';
}
?>
<input name="envoi" value="ENVOYER" type="submit">
</form>
</div>