<?php
if (@$_POST['nom'] != "" && $_POST['prenom'] != "" && $_POST['societe'] != "" && $_POST['email'] != "" && $_POST['telephone'] != "" && $_POST['noserie'] != "" && $_POST['imei'] != "" && $_POST['iagree1'] == "oui" && $_POST['iagree2'] == "oui"){
if ($_POST['email']){
$okay = preg_match('/^[A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/', $_POST['email']);
if ($okay){
isset($db);
}
else {
echo "<body bgcolor=#6699ff>";
echo "<center>Corriger votre e-mail <br>";
echo "<a href='telecharge.php'>Retour</a></center>";
echo "</body>";
exit;
}
if ($_POST['telephone']){
$number = preg_match('/^[0-9]{10,}/',$_POST['telephone']);
if ($number) {
isset($db);
}
else {
echo "<body bgcolor=#6699ff>";
echo "<center>Le numéro de téléphone doit être des chiffres sans espace, sans tirait ni de caractères spéciaux
<br>";
echo "<a href='telecharge.php'>Retour</a></center>";
echo "</body>";
exit;
}
}
}
//connect to database server
$db=mysql_connect("localhost","root") or die ("cant connect");
//connect to database
mysql_select_db("smart",$db) or die ("cant connect");
//sql search request
//@$query="SELECT * FROM visiteur where IMEI='".$imei."';";
$imei=$_POST['imei'];
$query="SELECT * FROM visiteur where IMEI= $imei";
$result = mysql_query($query);
$found = 0;
while($row=mysql_fetch_array($result)){
if ( ($row["IMEI"] == $imei) ){
header("Location: [url]http://localhost/smart-phones/pdadownload.htm[/url]");
$found = 1;
break;
}
}
if($found == 0){
$nom=$_POST['nom'];
$prenom=$_POST['prenom'];
$societe=$_POST['societe'];
$email=$_POST['email'];
$telephone=$_POST['telephone'];
$imei=$_POST['imei'];
$noserie=$_POST['noserie'];
$iagree1=$_POST['iagree1'];
$iagree2=$_POST['iagree2'];
@$add="INSERT INTO visiteur VALUES (CURDATE(),'$nom', '$prenom', '$societe', '$email', '$telephone', '$imei', '$noserie','$iagree1', '$iagree2')";
if(mysql_query($add)){
header("Location: [url]http://localhost/smart-phones/pdadownload.htm[/url]");
}
else {
echo "Error";
}
}
}
else{
echo <<<FormDisplay
<form method='post' action='/smart-phones/telecharge.php'>
<table width='80%' border='0' cellspacing='1' cellpadding='1'>
<tr>
<td>Pour pouvoir télécharger, veuillez remplisez les champs
obligatoires suivants:</td>
</tr>
<tr>
<td>Nom*:
<input name='nom' type='text' id='nom'></td>
</tr>
<tr>
<td height='21'>Prenom*:
<input name='prenom' type='text' id='prenom'></td>
</tr>
<tr>
<td>Société*:
<input name='societe' type='text' id='societe'></td>
</tr>
<tr>
<td>Email*:
<input name='email' type='text' id='email'></td>
</tr>
<tr>
<td>Téléphone Mobile*:
<input name='telephone' type='text' id='telephone'></td>
</tr>
<tr>
<td>N° de Serie*:
<input name='noserie' type='text' id='noserie'></td>
</tr>
<tr>
<td>IMEI*:
<input name='imei' type='text' id='imei'></td>
</tr>
<tr>
<td><font size='1'>(*) champ obligatoire</font></td>
</tr>
<tr>
<td><p>
<input name='iagree1' type='checkbox' id='iagree1' value='oui' checked>
Acceptez-vous de recevoir des SMS, email, diffuser par smart-phones.fr,
que ce soit a titre commercial ou pour recevoir des informations techniques
sur le ou les produits que vous avez enregistrés ?<br>
<br>
<input name='iagree2' type='checkbox' id='iagree2' value='oui' checked>
Je télécharge et je suis totalement responsable de mon
acte, en aucun cas Dangaard Telecom France ne pourra être tenu
responsable de ma manipulation, ni de l’installation de logiciels
tierces.<br>
</p></td>
</tr>
<tr>
<td><input type='submit' name='Submit' value='Envoyez'></td>
</tr>
</table>
<p> </p>
</form>
FormDisplay;
}
?>
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv='Content-Type' content="text/html; charset=iso-8859-1">
</head>
<body><form method="post" action="/smart-phones/telecharge.php">
<tr>
<td>Saissisez votre code IMEI, si vous nous avez déjà contacter:</td>
</tr>
<tr>
<td>IMEI:
<input name="imei" type="text" id="imei">
<input type="submit" name="Submit2" value="Envoyez"></td>
</tr></form>
</body>
</html>
That's what i was talking about. Delete your code above, and use this.
I would tell you to do this:
-- Print out the $POST['imei'] variable
-- Try using isset($POST['']) rather than != ""
-- Try using !empty($_POST['']) as well
~Brett