bonjour,
j'ai vraiment besoin qu'un grand dévellopeur php m'aide.
mon
probleme est que j'au creer un jeu d'enregistrement grace a dreamweaver
et dans mon formulaire d'enregistrement dans ma console admin je
voudrais pouvoir envoier des images et du texte ect...
je ne
sais pas comment relier un script pour uploader mes 3 images sur mon
serveur et en meme temps les donnees s'ecrivent dans ma base de donnees
pour que je puisse les modifier et les resortir sur ma page de site.
je ne suis pas tres fort en php, voir tres nul, et j'ai vraiment besoin d'aide.
je
vous met le script de ma page d'ajout d'une location, c'est à dire la
page ou je veux inserer mon texte et mes images. ( j'ai aussi une page
pour modifier ces donees )
comment faire ?
<?php require_once('../../Connections/localhost.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "1";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "../loginfailed.php";
if
(!((isset($_SESSION['MM_Username'])) &&
(isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'],
$_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?><?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO _location (`_categorie_id_categorie`,
id_location, nom_location, detailmin_location, detailmax_location,
reference_location, prix_location, nbredechambre_location,
nbredepiece_location, surface_location, img_max1_location,
img_max2_location, img_min_location) VALUES (%s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['select'], "int"),
GetSQLValueString($_POST['id_loc'], "int"),
GetSQLValueString($_POST['nom_location'], "text"),
GetSQLValueString($_POST['detailmin_location'], "text"),
GetSQLValueString($_POST['detailmax_location'], "int"),
GetSQLValueString($_POST['reference_location'], "text"),
GetSQLValueString($_POST['prix_location'], "text"),
GetSQLValueString($_POST['nbredechambre_location'], "int"),
GetSQLValueString($_POST['nbredepiece_location'], "int"),
GetSQLValueString($_POST['surface_location'], "int"),
GetSQLValueString($_POST['img_max1_location'], "text"),
GetSQLValueString($_POST['img_max2_location'], "text"),
GetSQLValueString($_POST['img_min_location'], "text"));
mysql_select_db($database_localhost, $localhost);
$Result1 = mysql_query($insertSQL, $localhost) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_localhost, $localhost);
$query_location = "SELECT * FROM `_location`";
$location = mysql_query($query_location, $localhost) or die(mysql_error());
$row_location = mysql_fetch_assoc($location);
$totalRows_location = mysql_num_rows($location);
mysql_select_db($database_localhost, $localhost);
$query_Recordset1 = "SELECT * FROM `_categorie`";
$Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
if( isset($_POST['upload']) ) // si formulaire soumis
{
$content_dir = 'upload/'; // dossier où sera déplacé le fichier
$tmp_file = $_FILES['fichier']['tmp_name'];
if( !is_uploaded_file($tmp_file) )
{
exit("Le fichier est introuvable");
}
// on vérifie maintenant l'extension
$type_file = $_FILES['fichier']['type'];
if( !strstr($type_file, 'jpg') && !strstr($type_file, 'jpeg')
&& !strstr($type_file, 'bmp') && !strstr($type_file,
'gif') )
{
exit("Le fichier n'est pas une image");
}
// on copie le fichier dans le dossier de destination
$name_file = $_FILES['fichier']['name'];
if( !move_uploaded_file($tmp_file, $content_dir . $name_file) )
{
exit("Impossible de copier le fichier dans $content_dir");
}
echo "Le fichier a bien été uploadé";
}
?>
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1">
<table align="center">
<tr valign="baseline">
<td width="151" align="right" nowrap><span
class="Style2">Catégories d'appartement
</span></td>
<td width="276"><span class="Style2">
<label>
<select name="select" size="1">
<?php
do {
?>
<option value="<?php echo
$row_Recordset1['id_categorie']?>"<?php if
(!(strcmp($row_Recordset1['id_categorie'],
$row_Recordset1['id_categorie']))) {echo "selected=\"selected\"";}
?>><?php echo
$row_Recordset1['nom_categorie']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select>
</label>
</span></td>
</tr>
<tr valign="baseline">
<td align="right"><span class="Style2">Nom location </span></td>
<td><input name="nom_location" type="text" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td align="right"><span class="Style2">petite description</span></td>
<td><span class="Style2">
<textarea name="detailmin_location" cols="32"></textarea>
</span></td>
</tr>
<tr valign="baseline">
<td align="right"><span class="Style2">Description complète </span></td>
<td><span class="Style2">
<textarea name="detailmax_location" cols="32"></textarea>
</span></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style2">Reference de la location </span></td>
<td><input name="reference_location" type="text" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style2">Prix</span></td>
<td><input name="prix_location" type="text" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style2">Nombre de chambre</span></td>
<td><input name="nbredechambre_location" type="text" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style2">nombre de pièce </span></td>
<td><input name="nbredepiece_location" type="text" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style2">Surface au m² </span></td>
<td><input name="surface_location" type="text" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style2">grande image gauche </span></td>
<td><input name="img_max1_location" type="file" value="" size="32" content_dir="img/" />
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style2">grande image droite</span></td>
<td><input name="img_max2_location" type="file" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style2">image petite description </span></td>
<td><input name="img_min_location" type="file" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><span class="Style2"></span></td>
<td><input type="submit" value="Insérer l'enregistrement"></td>
</tr>
</table>
<input name="id_loc" type="hidden" id="id_loc" />
<input type="hidden" name="MM_insert" value="form1">
</form>
pour m'aider si vous avez besoin des page, voir du site ou d'une parti, demander moi.. mais aidez moi stp