Jump to content

carlitoway

New Members
  • Posts

    7
  • Joined

  • Last visited

carlitoway's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi guys Im trying to save multiples images with php, and I did it, but when I save the link on the Database, if I upload 3 images, its show 2 empty links with the raname name I had created, i would like when users upload 3 images its generate Just the 3 url of the images he/she upload, also I would like to save the first image on a diferent var ($foto), im will appreciate any hepl from you! thank you so much this is my code HTML: <form enctype="multipart/form-data" action="recursos/form_process.php" method="POST"> <div id="text"> <div> <input name="data[]" id="file" type="file" multiple="multiple" /> </div> </div> <input type="button" id="add-file-field" name="add" value="Agregar otra foto" /> <input type='hidden' name="action" value="uploadfiles" /> <input type="submit" class="formsubmit" value="Subir y terminar" /> </form> PHP <?php session_start(); include('conexion.php'); if(isset($_POST['action'])=='uploadfiles') { //Rename variables $time = time(); $random = substr(number_format(time() * rand(),0,'',''),0,10); $seed = str_split('AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789' ); shuffle($seed); $rand = '' ; foreach (array_rand($seed, 10) as $k) $rand .= $seed[$k]; //NEW NAME CODE $new_name = "$rand" . "$random" . "$time"; $upload_directory = '../uploads/'; $count_data = count($_FILES['data']) ; $upload = $_FILES['data']['name'][$x].','; for($x=0;$x<$count_data;$x++) { $upload .= $new_name . $_FILES['data']['name']["$x" . ""].','; ##### column Name you can use comma in ending use to stored like this for ex: first.jpg,second.jpg,third.png like this it will stored into database ####### move_uploaded_file($_FILES['data']['tmp_name'][$x], $upload_directory . $new_name . $_FILES['data']['name'][$x]); } $con = "INSERT INTO provicional (fotos) values ('$upload')"; $query = mysql_query($con); } ?>
  2. Thank you very much bro! its was more simple that i thought
  3. Hi every one! here is my problem,my code works fine, if my two values(id, contrasena) are correct, then de row its eliminated and the message is "DELETE DATA SUCCESSFULY" but when one of this doesnt match it send me the same message! and i dont know how to do it for send other message like "Password or ID or email are invalid" <?php $id = $_POST["id"]; $contrasena = $_POST["contrasena"]; $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } $sql = "DELETE FROM provicional WHERE (id, contrasena) = ($id, '$contrasena')"; mysql_select_db('propiedades'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not delete data: ' . mysql_error()); } echo "Deleted data successfully\n"; mysql_close($conn); ?> Many thanks for you help...!!
  4. I have this code and it works perfect with one image, but I need to upload more images (10) , can someone please help me with this problem...??? this is my Code <!DOCTYPE html> <html> <body> <h2>Subir imagen</h2> <form method="POST" enctype="multipart/form-data" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" > <input type="file" name="imagen"/> <input name="enviar" type="submit" value="Enviar"/> </form> </body> </html> <?php $host = "localhost"; $user = "root"; $pw = ""; $bd = "base"; $conexion=mysql_connect('localhost','root','') or die ('no hay conexion a la base de datos'); $db=mysql_select_db('base',$conexion) or die ('no existe la base de datos'); $RutaServidor='imagenes-de-usuarios'; $RutaTemporal=$_FILES['imagen']['tmp_name']; $NombreImagen=$_FILES['imagen']['name']; $SizeImagen=$_FILES['imagen']['size']; $rutaDestino=$RutaServidor.'/'.$SizeImagen.$NombreImagen; move_uploaded_file($RutaTemporal,$rutaDestino); $sql="INSERT INTO imagenes (ruta) values ('".$rutaDestino."')"; $respuesta=mysql_query($sql,$conexion); if ($respuesta){ echo ' <div class="subido"> <h2>Imagen guardada con exito</h2> <br> <h2 class="close-window2">Continuar</h2> </div>'; }else { echo 'no se puedo guardar la imagen intentelo de nuevo'; } ?>
  5. WOW THIS REALLY WORKS NOW!!!! MANY MANY THANKS GUYS I DO APPRECIATE YOUR HELP! and now I will leave the entre code to all those guys who will search for the same thing! this is really important and all thanks to you guyz DavidAM and Barand and Filecipher& Adrian Hendrich from google+ <div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method='POST'> <p>Tipo</p> <select name="opt1"> <option selected>all</option> <option value="apartamentos">Apartamentos</option> <option value="nave">Naves</option> <option value="penthouse">Penthouse</option> <option value="residencia">Residencias</option> <option value="villa">Villas</option> </select> <p>Ciudad</p> <select name="opt2"> <option selected>all</option> <option value="santo domingo">Santo Domingo</option> <option value="santiago">Santiago</option> <option value="samana">Samana</option> <option value="punta cana">punta cana</option> </select> <p>Precios</p> <select name="opt3"> <option selected>all</option> <option value="terrenas">terrenas</option> <option value="bavaro">bavaro</option> <option value="naco">naco</option> </select> <input type='submit'> </form> <?php include ("conexion.php"); $opt1 = $_POST['opt1']; $opt2 = $_POST['opt2']; $opt3 = $_POST['opt3']; $result = mysql_query(" SELECT * FROM `inmuebles` WHERE tipo = '".$opt1."' OR ciudad = '".$opt2."' OR sector = '".$opt3."' "); if (mysql_num_rows($result)) { echo "<TABLE>"; while ($row = mysql_fetch_array($result)) { echo " <tr> <td>" .$row["tipo"]. "</td> <td>" .$row["ciudad"]. "</td> <td>" .$row["sector"]. "</td> </tr>"; } echo "</TABLE>"; } ?> </div> thank you very much for your help guyz! God bless you all
  6. Thank you Barad... my code was wrong in the select SQL Now its works but just show me one record and the same code on my PhpmyAdmin works perfectly and show me all the Records, and now i dont know what im doing wrong.... this is what i have change and I also did what you said.. Thank you very much bro! $result = mysql_query(" SELECT * FROM `inmuebles` WHERE tipo = '".$opt1."' OR ciudad = '".$opt2."' OR sector = '".$opt3."' ");
  7. Hello guys, Im new in php and im trying to creat a multi inputs search... here is my problem I want to search on three inputs select (tipo,ciudad and precio) searching on the web i have this code, but it doesnt work, just show me "Not results" so here is my code, any help will be appreciated <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method='post'> <p>Tipo</p> <select name="opt1"> <option value="" selected>all</option> <option value="nave">Naves</option> <option value="penthouse">Penthouse</option> <option value="residencia">Residencias</option> <option value="villa">Villas</option> </select> <p>Ciudad</p> <select name="opt2"> <option value="santo domingo">Santo Domingo</option> <option value="samana">Samana</option> </select> <p>Precios</p> <select name="opt3"> <option value="terrenas">terrenas</option> </select> <input type='submit'> </form> <?php include ("conexion.php"); $opt1 = $_POST['opt1']; $opt2 = $_POST['opt2']; $opt3 = $_POST['opt3']; $result = mysql_query("SELECT * FROM `inmuebles` WHERE `tipo` = '".$opt1."' AND `ciudad` = '".$opt2."' AND `sector` = '".$opt3."'"); if ($row = mysql_fetch_array($result)){ echo " <table> <tr> <td>" .$row["tipo"]. "</td> <td>" .$row["ciudad"]. "</td> <td>" .$row["sector"]. "</td> </tr> </table> "; } else { echo "<div class='container' style='text-align:center;'>No disponible</div>"; } ?> </div> Any help will be appreciated
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.