je vais te mettre la totalité des script tu comprendra .
ajout d'annonce
<?php
include("sources/secuk.php");
include("cssstyle/haut.php");
include("func.php");
$htmlData = '';
if (!empty($_POST['description'])) {
if (get_magic_quotes_gpc()) {
$htmlData = stripslashes($_POST['description']);
} else {
$htmlData = $_POST['description'];
}
}
?>
<link rel="stylesheet" type="text/css" href="tcal.css" />
<script type="text/javascript" src="tcal.js"></script>
<script charset="utf-8" src="kindeditor.js"></script>
<script>
KE.show({
id : 'description',
cssPath : 'styles.css',
afterCreate : function(id) {
KE.event.ctrl(document, 13, function() {
KE.sync(id);
document.forms['example'].submit();
});
KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {
KE.sync(id);
document.forms['example'].submit();
});
}
});
/*********************date***************************/
$(function() {
$( "#datepicker" ).datepicker({
showOn: "button",
dateFormat: 'yy-mm-dd',
buttonImage: "cssstyle/imdesign/calendar.gif",
buttonImageOnly: true
});
});
/***************************************************/
$(document).ready(function() {
$('#wait_1').hide();
$('#drop_1').change(function(){
$('#wait_1').show();
$('#result_1').hide();
$.get("func.php", {
func: "drop_1",
drop_var: $('#drop_1').val()
}, function(response){
$('#result_1').fadeOut();
setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400);
});
return false;
});
});
function finishAjax(id, response) {
$('#wait_1').hide();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}
</script>
<style type="text/css">
.choix {
font-size: 9px;
}
</style>
<br />
<table width="650" border="0" align="center"><form method="post" action="aj_add_annonce.php">
<tr>
<td width="619">
<table width="100%" border="0">
<tr>
<td><img src="images/icones_00243.png" width="50" height="50" />
<div align="center"><b><font color="#0099CC">Ajouter votre annonce gratuitement </font></b></div>
</td>
</tr>
</table>
<table width="100%" border="0">
<tr>
<td width="21%"><b>Nom<img src="images/force.gif" width="16" height="16" /> :</b></td>
<td width="34%"><input type="hidden" name="nom" value="<?php echo $pseudom; ?>" />
<b><?php echo $pseudom; ?></b></td>
<td width="15%"><b>Email<img src="images/force.gif" alt="" width="16" height="16" /> :</b></td>
<td width="30%"><input type="hidden" name="email" value="<?php echo $_SESSION['email']; ?>" />
<b><?php echo $_SESSION['email']; ?></b></td>
</tr>
<tr>
<td width="21%"><b>Adresse du bien:</b></td>
<td width="34%">
<input class="input" type="text" name="adresse" id="adresse" /></td>
<td width="15%"><b>Code postale :</b></td>
<td width="30%">
<input class="input" type="text" name="cp" size="5" maxlength="4"/></td>
</tr>
<tr>
<td><b>Numéro :</b></td>
<td>
<input class="input" type="text" name="numero" size="5" maxlength="4" onKeyUp="verif_nombre(this);"/></td>
<td><b>Boîte :</b></td>
<td>
<input class="input" type="text" name="boite" size="5" maxlength="4" onKeyUp="verif_nombre(this);"/></td>
</tr>
<tr>
<td><b>Province :</b></td>
<td><select class="select" name="drop_1" id="drop_1">
<option value="" selected="selected" disabled="disabled">Select a Category</option>
<?php getTierOne(); ?>
</select>
</td>
<td><b>Ville :</b></td>
<td><span id="wait_1" style="display: none;">
<img alt="Please Wait" src="cssstyle/imdesign/ajax-loader.gif"/>
</span>
<span id="result_1" style="display: none;"></span>
</td>
</tr>
<tr>
<td><b>Téléphone<img src="images/force.gif" alt="" width="16" height="16" /> :</b></td>
<td>
<input class="input" type="text" name="telph" id="telph" /></td>
<td><b>Portable :</b></td>
<td>
<input class="input" type="text" name="gsmt" id="gsmt" /></td>
</tr>
<tr>
<td><b>Type de bien :</b></td>
<td>
<select class="select" name="type_bien"/>
<option value="Appartement à Louer">Appartement à Louer</option>
<option value="Appartement à Vendre">Appartement à Vendre</option>
<option value="Chalet à Louer">Chalet à Louer</option>
<option value="Chalet à Vendre">Chalet à Vendre</option>
<option value="Meublé à Louer">Meublé à Louer</option>
<option value="Collocation">Collocation</option>
<option value="Ferme à Louer">Ferme à Louer</option>
<option value="Ferme à Vendre">Ferme à Vendre</option>
<option value="Gîte à Louer">Gîte à Louer</option>
<option value="Gîte à Vendre">Gîte à Vendre</option>
<option value="Kots à Louer">Kots à Louer</option>
<option value="Kots à Vendre">Kots à Vendre</option>
<option value="Maison à Louer">Maison à Louer</option>
<option value="Maison à Vendre">Maison à Vendre</option>
<option value="Studio à Louer">Studio à Louer</option>
<option value="Studio à Vendre">Studio à Vendre</option>
<option value="Terrain à Bâtir">Terrain à Bâtir</option>
<option value="Terrain Agricole">Terrain Agricole</option>
</select></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>Prix du bien<img src="images/force.gif" alt="" width="16" height="16" /> :</b></td>
<td>
<input class="input" type="text" name="prixb" onKeyUp="verif_nombre(this);" size="10"/></td>
<td><b>Cadastre :</b></td>
<td>
<input class="input" type="text" name="prixc" size="10" onKeyUp="verif_nombre(this);"/></td>
</tr>
<tr>
<td><b>Nombre de chambre :</b></td>
<td><select class="select" name="ch">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>Superficie bâtiment :</b></td>
<td>
<input class="input" type="text" name="supb" onKeyUp="verif_nombre(this);"/></td>
<td><b>Terrain :</b></td>
<td>
<input class="input" type="text" name="supt" onKeyUp="verif_nombre(this);"/></td>
</tr>
<tr>
<td><b>Libre Quand<img src="images/force.gif" alt="" width="16" height="16" /> :</b></td>
<td>
<input class="input" type="text" name="libre" id="datepicker" size="10" /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>Type de vente</b><b><img src="images/force.gif" alt="" width="16" height="16" /></b> :</td>
<td>
<select class="select" name="vendeur" >
<option value="Enchère">Enchère</option>
<option value="Notaire">Notaire</option>
<option value="Particulier">Particulier</option>
<option value="Viager">Viager</option>
</select></td>
<td> </td>
<td> </td>
</tr>
</table>
<table width="100%" border="0">
<tr>
<td><p><b>Description du Bien<img src="images/force.gif" alt="" width="16" height="16" /> :</b></p>
<p><?php echo $htmlData; ?>
<label for="textarea"></label>
<textarea class="textarea" id="description" name="description" style="width:530px;height:200px;visibility:hidden;">
<?php echo htmlspecialchars($htmlData); ?></textarea>
</p></td>
</tr>
<tr>
<td><center><input type="submit" name="Submit" value="Valider"></center>
</td>
</tr>
</table>
</td>
</tr></form>
</table>
<br /><br />
<?php
//Page du bas
include("cssstyle/bas.php");
?>
la func.php
<?php
//**************************************
// Page load dropdown results //
//**************************************
function getTierOne()
{
$result = mysql_query("SELECT DISTINCT tier_one FROM two_drops")
or die(mysql_error());
while($tier = mysql_fetch_array( $result ))
{
echo '<option value="'.$tier['tier_one'].'">'.$tier['tier_one'].'</option>';
}
}
//**************************************
// First selection results //
//**************************************
if(@$_GET['func'] == "drop_1" && isset($_GET['func'])) {
drop_1($_GET['drop_var']);
}
function drop_1($drop_var)
{
include_once('sources/config.php');
$result = mysql_query("SELECT * FROM two_drops WHERE tier_one='$drop_var'")
or die(mysql_error());
echo '<select class="select" name="tier_two" id="tier_two">
<option value=" " disabled="disabled" selected="selected">Choose one</option>';
while($drop_2 = mysql_fetch_array( $result ))
{
$tier_two = $drop_2['tier_two'];
echo '<option value="'.$tier_two.'">'.$tier_two.'</option>';
}
echo '</select> ';
}
?>
Et enfin la page d'insertion
<?php
include("sources/secuk.php");
include("cssstyle/haut.php");
$add=0;
$adresse = addslashes(htmlspecialchars($_POST['adresse']));
$cp = addslashes(htmlspecialchars($_POST['cp']));
$province = $_POST['drop_1'];
$ville = $_POST['tier_two'];
$phone = addslashes(htmlspecialchars($_POST['telph']));
$gsm = addslashes(htmlspecialchars($_POST['gsmt']));
$typb = addslashes(htmlspecialchars($_POST['type_bien']));
$prixb = addslashes(htmlspecialchars($_POST['prixb']));
$prixc = addslashes(htmlspecialchars($_POST['prixc']));
$ch = addslashes(htmlspecialchars($_POST['ch']));
$libre = addslashes(htmlspecialchars($_POST['libre']));
$supb = addslashes(htmlspecialchars($_POST['supb']));
$supt = addslashes(htmlspecialchars($_POST['supt']));
$vendeur = addslashes(htmlspecialchars($_POST['vendeur']));
$description = addslashes(htmlspecialchars($_POST['description']));
//Verifie l'adresse est correct uniquement des lettres //window.location.href = ("http://127.0.0.1/hesbaye/add_annonce.php?idm='.$_SESSION['idm'].'");
$motif_adresse ='/^[a-z- ]{5,80}$/i';
if(!preg_match($motif_adresse,$adresse))
{
echo' <script>
$(document).ready(function() {
$("#dialog").dialog({
minWidth: 400 ,
height: 120,
position: [400,250],
buttons: { "Ok": function() {
history.go(-1);
return false; { $(this).dialog("close"); } } }
}); });
</script>';
echo'<div align="center" id="dialog" title="Erreur">Votre adresse est incorrect uniquement des lettres !!!!</div>';
include("cssstyle/bas.php");
$add=0;
return FALSE;
}
else{
$adresse;
}
//Verifie lecode postal est correct uniquement des chiffres //window.location.href = ("http://127.0.0.1/hesbaye/add_annonce.php?idm='.$_SESSION['idm'].'");
$motif_cp ='/^[0-9]{4}$/i';
if(!preg_match($motif_cp,$cp))
{
echo' <script>
$(document).ready(function() {
$("#dialog").dialog({
minWidth: 400 ,
height: 120,
position: [400,250],
buttons: { "Ok": function() {
history.go(-1);
return false;
{ $(this).dialog("close"); } } }
}); });
</script>';
echo'<div align="center" id="dialog" title="Erreur">Votre code postal est incorrect 4 chiffres!!!!</div>';
include("cssstyle/bas.php");
$modif=1;
return FALSE;
}
else{
$cp;
}
//contrôle du numéro de téléphone 000.00.00.00 ou 00.000.00.00//
$motif ='/^(\d{2}[-\s.]\d{3}|\d{3}[-\s.]\d{2})([-\s.]\d{2}){2}$/';
if(!preg_match($motif,$phone))
{
echo' <script>
$(document).ready(function() {
$("#dialog").dialog({
minWidth: 400 ,
height: 140,
position: [400,250],
buttons: { "Ok": function() {
window.location.href = ("http://127.0.0.1/hesbaye/modifier.php?idm='.$_SESSION['idm'].'"); { $(this).dialog("close"); } } }
}); });
</script>';
echo'<div align="center" id="dialog" title="Erreur">Votre numéro de téléphone est incorrect!!!!<br />
Exemple : 000.00.00.00 ou 00.000.00.00</div>';
include("cssstyle/bas.php");
$add=1;
return FALSE;
}
else{
$phone;
}
//contrôle du numéro de portable//
if(!empty($gsm))
{
$motif_p ='/\(?\d{4}\)?[-\s.]?\d{3}[-\s.]\d{3}/x';
if(!preg_match($motif_p,$gsm))
{
echo' <script>
$(document).ready(function() {
$("#dialog").dialog({
minWidth: 400 ,
height: 140,
position: [400,250],
buttons: { "Ok": function() {
window.location.href = ("http://127.0.0.1/hesbaye/modifier.php?idm='.$_SESSION['idm'].'"); { $(this).dialog("close"); } } }
}); });
</script>';
echo'<div align="center" id="dialog" title="Erreur">Votre numéro de portable est incorrect!!!!<br /> Exemple : 0000.000.000</div>';
include("cssstyle/bas.php");
$modif=1;
return FALSE;
}
else{
$gsm;
}
}
if ($add==0){
@mysql_query("INSERT INTO annonce (nom, email, adresse, cp, province, ville, phone, gsm, typeb, prixb, prixc, ch, supb, supc, libreq, vendeur )
VALUES ('$nom', '$email', '$adresse', '$cp', '$province', '$ville', '$phone', '$gsm', '$typb', '$prixb',
'$prixc', '$ch', '$supb', '$supt', '$libre', '$vendeur')")
or die (mysql_error());
echo '<center><b>Votre annonce à bien été placé</b><br /><br />
<a href=\"compte.php\">Ajouter vos photos</a><br /></center><br />';
unset($_COOKIE['tier_two']);
}
else {
echo '<center><b>L´insertion à rater</b><br><br>';
unset($_COOKIE['tier_two']);
}
mysql_close();
include("cssstyle/bas.php");
?>