Jump to content

emediastudios

Members
  • Posts

    418
  • Joined

  • Last visited

Posts posted by emediastudios

  1. I have a search page, when someone clicks on a property they are interested in it takes them to a show property details page that draws all the images and sql data for that perticular property, this page is filled by carrying form varibles.

    How do i set up a link for ppl to add that property to a shortlist? and return to that page at a later date, as i have it it adds that page to there favorites and when they return the page is empty as no data has been called.

    I know there is a way but i dont know how to redraw the data on the property they are interested in, Do i use a cookie here?

    I have never worked with cookies and have no clue.

     

    Thanks to anyone that can help. ;)

  2. I have this code i usethat works fine, except that any filr can be uploaded and any size.

    How would i add some code to check that the file is a jpeg, gif or png and is under 1 meg?

     

    Thanks in advance

     

    Code below........................

     

    <?php 
    
    //This is the directory where images will be saved 
    $path = '../images/';
    
    //This gets all the other information from the form 
    $name=$_POST['name']; 
    $suburb=$_POST['suburb']; 
    $price=$_POST['price']; 
    $content=$_POST['content']; 
    $uploadFile0=($_FILES['uploadFile0']['name']); 
    $uploadFile1=($_FILES['uploadFile1']['name']);
    $uploadFile2=($_FILES['uploadFile2']['name']);
    $uploadFile3=($_FILES['uploadFile3']['name']);
    $uploadFile4=($_FILES['uploadFile4']['name']);
    $uploadFile5=($_FILES['uploadFile5']['name']);
    $uploadFile6=($_FILES['uploadFile6']['name']);
    $uploadFile7=($_FILES['uploadFile7']['name']);
    $uploadFile8=($_FILES['uploadFile8']['name']);
    
    
    
    // Connects to your Database 
    mysql_connect("localhost", "root", "password") or die(mysql_error()) ; 
    mysql_select_db("gcproperty") or die(mysql_error()) ; 
    
    
    //Writes the information to the database
    
    mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$uploadFile0', '$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')") ; 
    
    
    $uploadNeed = $_POST['uploadNeed'];
    // start for loop
    for($x=0;$x<$uploadNeed;$x++){
    $file_name = $_FILES['uploadFile'. $x]['name'];
    // strip file_name of slashes
    $file_name = stripslashes($file_name);
    $file_name = str_replace("'","",$file_name);
    $copy = move_uploaded_file($_FILES['uploadFile'. $x]['tmp_name'], $path . $file_name);
    
    }
    
    
    // check if successfully copied
    
    if($copy){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">";
    } else{
    echo "$file_name | could not be uploaded!<br>";
    }
    // end of loop
    ?>
    
    
    
    

  3. Huggie im so gratefull for your help but i did as u instructed and i get this error now

     

    Parse error: syntax error, unexpected T_ELSE in C:\Program Files\Apache Group\Apache2\htdocs\gcproperty\admin\add_test.php on line 46

     

    My full code is

    <?php 
    
    //This is the directory where images will be saved 
    $path = '../images/';
    
    //This gets all the other information from the form 
    $name=$_POST['name']; 
    $suburb=$_POST['suburb']; 
    $price=$_POST['price']; 
    $content=$_POST['content']; 
    $uploadFile0=($_FILES['uploadFile0']['name']); 
    $uploadFile1=($_FILES['uploadFile1']['name']);
    $uploadFile2=($_FILES['uploadFile2']['name']);
    $uploadFile3=($_FILES['uploadFile3']['name']);
    $uploadFile4=($_FILES['uploadFile4']['name']);
    $uploadFile5=($_FILES['uploadFile5']['name']);
    $uploadFile6=($_FILES['uploadFile6']['name']);
    $uploadFile7=($_FILES['uploadFile7']['name']);
    $uploadFile8=($_FILES['uploadFile8']['name']);
    
    
    
    // Connects to your Database 
    mysql_connect("localhost", "root", "5050888202") or die(mysql_error()) ; 
    mysql_select_db("gcproperty") or die(mysql_error()) ; 
    
    // Check the extension is valid
    if (preg_match('/\.(jpg|jpeg|gif|png)$/i', $_FILES['uploadFile'. $x]['name'])){
    
    
    //Writes the information to the database
    
    mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$uploadFile0', '$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')") ; 
    
    
    $uploadNeed = $_POST['uploadNeed'];
    // start for loop
    for($x=0;$x<$uploadNeed;$x++){
    $file_name = $_FILES['uploadFile'. $x]['name'];
    // strip file_name of slashes
    $file_name = stripslashes($file_name);
    $file_name = str_replace("'","",$file_name);
    $copy = move_uploaded_file($_FILES['uploadFile'. $x]['tmp_name'], $path . $file_name);
    
    }
    else {
       // Add your error code here
       echo "Sorry, file must be of type .jpg .jpeg .gif or .png\n";
    }
    
    
    
    
    // check if successfully copied
    
    if($copy){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">";
    } else{
    echo "$file_name | could not be uploaded!<br>";
    }
    } // end of loop
    ?>
    
    
    
    

     

    Many thanks

  4. Thanks 4 the speedy reply

     

    Heres what i did with ur instructions

     

    <?php 
    
    //This is the directory where images will be saved 
    $path = '../images/';
    
    //This gets all the other information from the form 
    $name=$_POST['name']; 
    $suburb=$_POST['suburb']; 
    $price=$_POST['price']; 
    $content=$_POST['content']; 
    $uploadFile0=($_FILES['uploadFile0']['name']); 
    $uploadFile1=($_FILES['uploadFile1']['name']);
    $uploadFile2=($_FILES['uploadFile2']['name']);
    $uploadFile3=($_FILES['uploadFile3']['name']);
    $uploadFile4=($_FILES['uploadFile4']['name']);
    $uploadFile5=($_FILES['uploadFile5']['name']);
    $uploadFile6=($_FILES['uploadFile6']['name']);
    $uploadFile7=($_FILES['uploadFile7']['name']);
    $uploadFile8=($_FILES['uploadFile8']['name']);
    
    
    
    // Connects to your Database 
    mysql_connect("localhost", "root", "5050888202") or die(mysql_error()) ; 
    mysql_select_db("gcproperty") or die(mysql_error()) ; 
    
    // Check the extension is valid
    if (preg_match('/\.(jpg|jpeg|gif|png)$/i', $_FILES['uploadFile'. $x]['name']){
    
    
    //Writes the information to the database
    
    mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$uploadFile0', '$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')") ; 
    
    
    $uploadNeed = $_POST['uploadNeed'];
    // start for loop
    for($x=0;$x<$uploadNeed;$x++){
    $file_name = $_FILES['uploadFile'. $x]['name'];
    // strip file_name of slashes
    $file_name = stripslashes($file_name);
    $file_name = str_replace("'","",$file_name);
    $copy = move_uploaded_file($_FILES['uploadFile'. $x]['tmp_name'], $path . $file_name);
    
    }
    else {
       // Add your error code here
       echo "Sorry, file must be of type .jpg .jpeg .gif or .png\n";
    }
    
    
    
    
    // check if successfully copied
    
    if($copy){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">";
    } else{
    echo "$file_name | could not be uploaded!<br>";
    }
    } // end of loop
    ?>
    
    
    
    

     

    But i get this error

     

    Parse error: syntax error, unexpected '{' in C:\Program Files\Apache Group\Apache2\htdocs\gcproperty\admin\add_test.php on line 28

     

    I delete the { and i get this error Parse error: syntax error, unexpected T_STRING in C:\Program Files\Apache Group\Apache2\htdocs\gcproperty\admin\add_test.php on line 33

     

     

     

  5. ;);D

    Your the best man, your awesome, problem solved!!

    Thanks so so much, i have been on this for nights on end.

     

    I dont mean to be asking too much but a simple filter for stopping the upload of something other that a gif, png or jpeg would be the icing on the cake.

     

    Or should i re post?

     

    So happy man, thanks again

  6. i used your code and added it mine as below

     

    <?php 
    
    //This is the directory where images will be saved 
    $target = "../images/";
    
    //This gets all the other information from the form 
    $name=$_POST['name']; 
    $suburb=$_POST['suburb']; 
    $price=$_POST['price']; 
    $content=$_POST['content']; 
    $uploadFile0=($_FILES['uploadFile0']['name']); 
    $uploadFile1=($_FILES['uploadFile1']['name']);
    $uploadFile2=($_FILES['uploadFile2']['name']);
    $uploadFile3=($_FILES['uploadFile3']['name']);
    $uploadFile4=($_FILES['uploadFile4']['name']);
    $uploadFile5=($_FILES['uploadFile5']['name']);
    $uploadFile6=($_FILES['uploadFile6']['name']);
    $uploadFile7=($_FILES['uploadFile7']['name']);
    $uploadFile8=($_FILES['uploadFile8']['name']);
    
    
    
    // Connects to your Database 
    mysql_connect("localhost", "emediast", "7833pjer") or die(mysql_error()) ; 
    mysql_select_db("emediast_gcproperty") or die(mysql_error()) ; 
    
    //Writes the information to the database 
    mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$uploadFile0', '$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')") ; 
    
    
    $uploadNeed = $_POST['uploadNeed'];
    // start for loop
    for($x=0;$x<$uploadNeed;$x++){
    $file_name = $_FILES['uploadFile'. $x]['name'];
    // strip file_name of slashes
    $file_name = stripslashes($file_name);
    $file_name = str_replace("'","",$file_name);
    $copy = copy($_FILES['uploadFile'. $x]['tmp_name'],$file_name);
    
    
    // Full path to image directory
    $path = '../images';
    
    // Move file to new location
    move_uploaded_file($_FILES['uploadFile'. $x]['tmp_name'], $path . $file_name);
    
    
    // check if successfully copied
    
    if($copy){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">";
    } else{
    echo "$file_name | could not be uploaded!<br>";
    }
    } // end of loop
    ?>
    
    
    
    

     

    It uploads the files and inserts the info into sql but still doesnt move the uploaded files to the new directory ../images

     

    No errors reported either, any ideas?

     

    Thanks for your help.

     

     

  7. I have finally worked out how to upload images and there names into a sql database. :)

    Question is how do i set the directory in which the images are posted?

     

    At present they are uploaded into the admin section of my site here the php file is, not really were i want ppl accessing the file from...

     

    Heres the code

     

    <?php 
    
    
    
    //This gets all the other information from the form 
    $name=$_POST['name']; 
    $suburb=$_POST['suburb']; 
    $price=$_POST['price']; 
    $content=$_POST['content']; 
    $uploadFile0=($_FILES['uploadFile0']['name']); 
    $uploadFile1=($_FILES['uploadFile1']['name']);
    $uploadFile2=($_FILES['uploadFile2']['name']);
    $uploadFile3=($_FILES['uploadFile3']['name']);
    $uploadFile4=($_FILES['uploadFile4']['name']);
    $uploadFile5=($_FILES['uploadFile5']['name']);
    $uploadFile6=($_FILES['uploadFile6']['name']);
    $uploadFile7=($_FILES['uploadFile7']['name']);
    $uploadFile8=($_FILES['uploadFile8']['name']);
    
    
    
    // Connects to your Database 
    mysql_connect("localhost", "root", "5050888202") or die(mysql_error()) ; 
    mysql_select_db("gcproperty") or die(mysql_error()) ; 
    
    //Writes the information to the database 
    mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$uploadFile0', '$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')") ; 
    
    
    $uploadNeed = $_POST['uploadNeed'];
    // start for loop
    for($x=0;$x<$uploadNeed;$x++){
    $file_name = $_FILES['uploadFile'. $x]['name'];
    // strip file_name of slashes
    $file_name = stripslashes($file_name);
    $file_name = str_replace("'","",$file_name);
    $copy = copy($_FILES['uploadFile'. $x]['tmp_name'],$file_name);
    // check if successfully copied
    if($copy){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">";
    } else{
    echo "$file_name | could not be uploaded!<br>";
    }
    } // end of loop
    ?>
    
    
    
    

  8. Thanks, i gave it a go, still inserts all the image names and other info but only uploads, the first (photo)

    Doesnt upload the other images to the directory (photo1 and photo2)

     

    This is what im using now

     

    ------------------------------------------------------------------------

     

    <?php

     

    //This is the directory where images will be saved

    $target = "../images/";

    $target = $target . basename( $_FILES['photo']['name']);

     

     

    //This gets all the other information from the form

    $name=$_POST['name'];

    $suburb=$_POST['suburb'];

    $price=$_POST['price'];

    $content=$_POST['content'];

    $photo=($_FILES['photo']['name']);

    $photo2=($_FILES['photo2']['name']);

    $photo3=($_FILES['photo3']['name']);

     

     

    // Connects to your Database

    mysql_connect("localhost", "root", "5050888202") or die(mysql_error()) ;

    mysql_select_db("gcproperty") or die(mysql_error()) ;

     

    //Writes the information to the database

    mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$photo', '$photo2', '$photo3')") ;

     

    //Writes the photo to the server

    if ( move_uploaded_file($_FILES['photo']['tmp_name'], $target) && move_uploaded_file($_FILES['photo2']['tmp_name'], $target) && move_uploaded_file($_FILES['photo3']['tmp_name'], $target) )

    {

     

     

     

    //Tells you if its all ok

    print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">";

    }

    else {

     

    //Gives and error if its not

    echo "Sorry, there was a problem uploading your file.";

    }

    ?>

  9. Hi all.

    I have a code that works fine except for one thing, it only uploads (1) image and i want to upload (4).

    the code i have does all ehat i want and inserts the file name in to my SQL database along with some other info.

    Can someone tell me how to alter my code to upload (4)images, and record there image name into sql.

    the code i have below i altered to process (3) pics but it doesnt upload the images and  only inserts there image file name into sql.

     

     

    Thanks so much...........

    Heres the code i have

     

    <?php

     

    //This is the directory where images will be saved

    $target = "../images/";

    $target = $target . basename( $_FILES['photo']['name']);

     

     

    //This gets all the other information from the form

    $name=$_POST['name'];

    $suburb=$_POST['suburb'];

    $price=$_POST['price'];

    $content=$_POST['content'];

    $pic=($_FILES['photo']['name']);

    $pic2=($_FILES['photo2']['name']);

    $pic3=($_FILES['photo3']['name']);

     

     

    // Connects to your Database

    mysql_connect("localhost", "root", "5050888202") or die(mysql_error()) ;

    mysql_select_db("gcproperty") or die(mysql_error()) ;

     

    //Writes the information to the database

    mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$pic', '$pic2', '$pic3')") ;

     

    //Writes the photo to the server

    if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))  --------------My problem needs to sorted here somewhere i think.

    {

     

    //Tells you if its all ok

    print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">";

    }

    else {

     

    //Gives and error if its not

    echo "Sorry, there was a problem uploading your file.";

    }

    ?>[/color]

     

  10. Hi all.

    I have a code that works fine except for one thing, it only uploads (1) image and i want to upload (4).

    the code i have does all ehat i want and inserts the file name in to my SQL database along with some other info.

    Can someone tell me how to alter my code to upload (4)images, and record there image name into sql.

    the code i have below i altered to process (3) pics but it doesnt upload the images and  only inserts there image file name into sql.

     

     

    Thanks so much........... ;)

    Heres the code i have

     

    <?php

     

    //This is the directory where images will be saved

    $target = "../images/";

    $target = $target . basename( $_FILES['photo']['name']);

     

     

    //This gets all the other information from the form

    $name=$_POST['name'];

    $suburb=$_POST['suburb'];

    $price=$_POST['price'];

    $content=$_POST['content'];

    $pic=($_FILES['photo']['name']);

    $pic2=($_FILES['photo2']['name']);

    $pic3=($_FILES['photo3']['name']);

     

     

    // Connects to your Database

    mysql_connect("localhost", "root", "5050888202") or die(mysql_error()) ;

    mysql_select_db("gcproperty") or die(mysql_error()) ;

     

    //Writes the information to the database

    mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$pic', '$pic2', '$pic3')") ;

     

    //Writes the photo to the server

    if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))  --------------My problem needs to sorted here somewhere i think.

    {

     

    //Tells you if its all ok

    print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">";

    }

    else {

     

    //Gives and error if its not

    echo "Sorry, there was a problem uploading your file.";

    }

    ?>[/color]

     

     

  11. Hi everyone!

    I'll try to explain this in simple words. :)

     

    I have a site im working on that lists properties with various photos and details that are drawn from an sql database.(no problems)

    This show records page shows all properties and a few details with the option to see more about any particular property.

    This link then takes you to a full details page that uses form varibles to populate the page, (no problem)

    The problem is my client wants a add to favorite / shortlist link that lets him go back to this page and the selected property.

    I did some code but does not work.

    when you go back to that same page directly it doesnt carry the form varibles and has no content.

     

    fav.js

     

    // Bookmark this page

    // copyright 12th February 2005, 21st June 2006

    // Stephen Chapman, http://javascript.about.com

    // Updated for Opera 9

    // You have permission to copy and use this javascript provided that

    // the copyright notice is included with the script

     

    var chr = 'CTRL-D';

    var agt=navigator.userAgent.toLowerCase();

    if(agt.substr(agt.indexOf('opera')+6,1) < 9) chr = 'CTRL-T';

    if (window.external) document.write('<a href="javascript:window.external.AddFavorite(self.location,document.title)"><img src="images/favourites.png" alt="add to favorites" border="0" /><\/a>');

    else document.write('Press '+chr+' to bookmark this page.');   

     

    and this is my link in my page

     

    <script type="text/javascript" src="favlink.js">

    </script>             

     

  12. Hey ben

    I Know it only works on the first phot because that's the only one specificed to move to your target folder, do you know an easy way to alter the code to include the other 2 files (photo2 and photo3) i will add some filters after i get the code working.

    Thanks for your help, is one of the the last problems i have in this project im doing, if you can help me i am willing to pay you, or donate to this site.

    Really want to wrap this up.

     

    it only works on the first phot because that's the only one specificed to move to your target folder, found here in your code...

     

    if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
    

     

    the code you have now is rather vulerable to mysql injection among other things, because you have no sort of filters for your photos and data input. but i'm too tired to go into that. try the code below. if it doesn't work, just copy the if else statement above (the WHOLE thing, including the else, "sorry...problem", and closing brace. and just change 'photo' to 'photo2', etc..

     

     

     

    
    
    <?php
    
    //This is the directory where images will be saved
    $target = "../images/";
    $target = $target . basename( $_FILES['photo']['name']);
    
    
    //This gets all the other information from the form
    $name=$_POST['name'];
    $suburb=$_POST['suburb'];
    $price=$_POST['price'];
    $content=$_POST['content'];
    $photo2=$_FILES['photo2']['name'];
    $photo3=$_FILES['photo3']['name'];
    $pic=($_FILES['photo']['name']);
    
    
    // Connects to your Database
    mysql_connect("localhost", "root", "**********") or die(mysql_error()) ;
    mysql_select_db("gcproperty") or die(mysql_error()) ;
    
    //Writes the information to the database
    mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$pic', '$photo2', '$photo3')") ;
    
    //Writes the photo to the server
    foreach($_FILES as $val){
      if(!move_uploaded_file($_FILES[$val]['tmp_name'], $target)){
        $error = yes;
      }
    }
    
    if($error){
      //Tells you if its all ok
      print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">";
    } else {
      //Gives and error if its not
      echo "Sorry, there was a problem uploading your file.";
    }
    ?>
    
    

  13. Hi there Ben

    Used the code, it goes to the successful page, but doesn’t upload the files, i get a white page with some code just after i hit the submit button but is to quick to read.

    Thanks for your help, im still stuck

     

  14. Hi,

    Can someone please help, i want to upload 3 images, this is a code i got off the net but only uploads one file, (photo)

    I have 2 new fields in my sql file called photo2 and photo3, the image names and all other information from the form get sent successfully , but i cannot work out how to upload the other 2 files,

    My field is called photo in my sql database but the code below uses the word (pic) i dont know why as i never wrote it but it works.

     

    i have this code i use in my add property file...

     

    <?php

     

    //This is the directory where images will be saved

    $target = "../images/";

    $target = $target . basename( $_FILES['photo']['name']);

     

     

    //This gets all the other information from the form

    $name=$_POST['name'];

    $suburb=$_POST['suburb'];

    $price=$_POST['price'];

    $content=$_POST['content'];

    $photo2=$_FILES['photo2']['name'];

    $photo3=$_FILES['photo3']['name'];

    $pic=($_FILES['photo']['name']);

     

     

    // Connects to your Database

    mysql_connect("localhost", "root", "**********") or die(mysql_error()) ;

    mysql_select_db("gcproperty") or die(mysql_error()) ;

     

    //Writes the information to the database

    mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$pic', '$photo2', '$photo3')") ;

     

    //Writes the photo to the server

    if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))

    {

     

     

    //Tells you if its all ok

    print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">";

    }

    else {

     

    //Gives and error if its not

    echo "Sorry, there was a problem uploading your file.";

    }

    ?>

×
×
  • 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.