Jump to content

Can you recommend a script???


carlmartin10

Recommended Posts

:facewall: I have been trying to write soem scripts but I am all turned around and confused. Hereis how I need this to all work:

 

Visitors use an HTML form to enter some information (name, state, etc.) and also upload some images. This form calls a PHP script that puts all of this information into a MySQL database (not sure if the images need to be BLOBS in the DB, or if they need to go to their own directory, and the location saved in the DB, and if they all go to a directory, they will need to be assigned unique values). Obviously this needs to have success/failure messages, and some security would be nice, maybe even reCAPTCHA. Once this is all stored in the database, I need a script that can be used to search these records, and then echo the information in the DB table matching the search parameters. All information and images should be echoed. It would be cool if the first pic was full size, and the others were thumbnails that could be resized by clicking them.  Anyone know where I can get a script like this?  I can not seem to get all this to work.  thanks! :facewall:

Link to comment
Share on other sites

This can be very simple if you do some research. Start by setting the variables

 

1. Your variables. These will be ofcourse name,state..etc

$name = $_POST['name'];
$state = $_POST['state'];
//...etc

 

2. Your users to be uploaded file details

$filename = $_FILES['userfile']['name'];
$filesize = $_FILES['userfile']['size'];
$filetype = $_FILES['userfile']['type'];
$path = "uploads/"; // Where the images will go
$target_path = $path . basename($filename);
$allowtypes = array(".png",".jpg",".gif"); // what file types are allow
$allowsize = 1024 // how big can the file be

 

3. Validate the NAME, STATE..etc

4. Validate the USERS FILE

5. Grab the image width and height, Clean the variables such as Name, State..etc, and see if the user's filename is exists in your "uploads/" folder, and rename it if it does....

6. save the details in your database

7. success/error message

Link to comment
Share on other sites

Visitors use an HTML form to enter some information (name, state, etc.)

http://www.lmgtfy.com/?q=html+form

 

and also upload some images. This form calls a PHP script that puts all of this information into a MySQL database (not sure if the images need to be BLOBS in the DB, or if they need to go to their own directory, and the location saved in the DB, and if they all go to a directory, they will need to be assigned unique values).

http://www.lmgtfy.com/?q=php+file+upload

http://www.lmgtfy.com/?q=php+image+upload

 

Obviously this needs to have success/failure messages, and some security would be nice,

http://www.lmgtfy.com/?q=php+form+validation

 

maybe even reCAPTCHA. Once this is all stored in the database, I need a script that can be used to search these records, and then echo the information in the DB table matching the search parameters. All information and images should be echoed.

http://www.lmgtfy.com/?q=recaptcha

 

 

It would be cool if the first pic was full size, and the others were thumbnails that could be resized by clicking them.  Anyone know where I can get a script like this?  I can not seem to get all this to work.  thanks! :facewall:

:headslap:

Link to comment
Share on other sites

Visitors use an HTML form to enter some information (name, state, etc.)

http://www.lmgtfy.com/?q=html+form

 

and also upload some images. This form calls a PHP script that puts all of this information into a MySQL database (not sure if the images need to be BLOBS in the DB, or if they need to go to their own directory, and the location saved in the DB, and if they all go to a directory, they will need to be assigned unique values).

http://www.lmgtfy.com/?q=php+file+upload

http://www.lmgtfy.com/?q=php+image+upload

 

Obviously this needs to have success/failure messages, and some security would be nice,

http://www.lmgtfy.com/?q=php+form+validation

 

maybe even reCAPTCHA. Once this is all stored in the database, I need a script that can be used to search these records, and then echo the information in the DB table matching the search parameters. All information and images should be echoed.

http://www.lmgtfy.com/?q=recaptcha

 

 

It would be cool if the first pic was full size, and the others were thumbnails that could be resized by clicking them.  Anyone know where I can get a script like this?  I can not seem to get all this to work.  thanks! :facewall:

:headslap:

 

thanks, I have googled this already. I exhausted all possibilities and this was my last resort. It is hard to find scripts that all work well together to pull off this whole operation. 

Link to comment
Share on other sites

I find it hard to believe you can't achieve this with the reference provided in this thread. You are just wanting someone to make this for you, use the freelance board.

 

What you posted was very helpful. I was commenting on the last poster, because those links were just Google searches. I have the HTML form going, the DB is set up, and I have the script written to add the info to the DB, but I am having trouble getting it to actually upload image files, and then create the necessary referrer in the DB.  This is the part that has me all worked up.  Once I get this part working, the rest is just pulling the record, and echoing the data.

Link to comment
Share on other sites

It is hard to find scripts that all work well together to pull off this whole operation.

 

That is indeed why its usually better to learn php and do things yourself.

 

I agree. That is what I am trying to do. The best teacher is experience, and failure.  I have had a lot of failure on this.  I have other PHP scripts that work great, this one is beyond my scope, and I am man enough to admit my limitations.  Thanks!

Link to comment
Share on other sites

I find it hard to believe you can't achieve this with the reference provided in this thread. You are just wanting someone to make this for you, use the freelance board.

 

What you posted was very helpful. I was commenting on the last poster, because those links were just Google searches. I have the HTML form going, the DB is set up, and I have the script written to add the info to the DB, but I am having trouble getting it to actually upload image files, and then create the necessary referrer in the DB.  This is the part that has me all worked up.  Once I get this part working, the rest is just pulling the record, and echoing the data.

 

 

Okay post your script so far, and show me what you have done. We will help you with the problem.

Link to comment
Share on other sites

I find it hard to believe you can't achieve this with the reference provided in this thread. You are just wanting someone to make this for you, use the freelance board.

 

What you posted was very helpful. I was commenting on the last poster, because those links were just Google searches. I have the HTML form going, the DB is set up, and I have the script written to add the info to the DB, but I am having trouble getting it to actually upload image files, and then create the necessary referrer in the DB.  This is the part that has me all worked up.  Once I get this part working, the rest is just pulling the record, and echoing the data.

 

 

Okay post your script so far, and show me what you have done. We will help you with the problem.

 

Thank you. I truly appreciate the help, and I am by no means looking for someone to do this for me...I really want to learn this so I know how to do it.  I have taught myself so far, and, although I am just getting started, I am getting better at it every day.  Here is the code I have...so far. This is trying to upload images as BLOBS, but I am not sure that is the way to do it.  I dont know how to add a referrer to the database, then have it called when the records match a search (I LEFT OUT THE DB CONNECT INFO, obviously):

<?php



     // Info from the form
    	$first=$_POST['first'];
$last=$_POST['last'];
$city=$_POST['city'];
$state=$_POST['state'];
$country=$_POST['country'];
$gender=$_POST['gender'];
$imageurl=$_POST['imageurl'];
$imageurl2=$_POST['imageurl2'];
$imageurl3=$_POST['imageurl3'];
$imageurl4=$_POST['imageurl4'];
$imageurl5=$_POST['imageurl5'];

    


     $max_size = 2000000;
     $filesize = $_FILES['upfile']['size'];
     $filetype = $_FILES['upfile']['type'];

        
       
    if ($filesize > $max_size){
           echo "Maximum File Size is 2MB.";
           exit;
        }
         
        
               
                
//  database connection

$username="";
$password="";
$database="";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO test VALUES ('','$first','$last','$city','$state','$country','$gender','$imageurl','$imageurl2','$imageurl3','$imageurl4','$imageurl25')";
mysql_query($query);

if($query) {
echo "You have successfully created an ExBrief !";
} else {
echo "Your ExBrief was not created.  Please review the information you entered for accuracy.";


mysql_close();
}  

?>

Link to comment
Share on other sites

Alright first of all, you must connect to the database before anything. It has to be top priority! Second BLOBS is a binary large object which can hold a variable amount of data. You only have to store the file names of the users file. Use VARCHAR.

 

You also need to make a folder where you are going to put the file (ex: "uploads/").

 

also how many files are the users going to upload? Seems like there are several here in the script.

 

Use this beginner's tutorial

 

http://www.tizag.com/phpT/fileupload.php

 

for file uploads to get to know the basics

Link to comment
Share on other sites

I have the script written to add the info to the DB, but I am having trouble getting it to actually upload image files, and then create the necessary referrer in the DB.  This is the part that has me all worked up.

This does sound more like you're actually willing to learn instead of makeing someone write it for you which is good.

 

Do be aware that when you combine regular form fields such as text input radio's and select pulldows with a file/image upload field the validation can become tricky.

 

For example, a user forgot to fill in the email field when this is a required field. This when he did select an image for uploading in the form. After the page got submitted he will receive a message where saying "you forgot to enter your email" (or something like that). Now since the user already selected the image you would want this image to be re-selected. That is a bit tricky.

 

Concerning the Blobtype vs storing just the name of the uploaded image. What i see mostly is that an image name is being stored inside the db. That way you can just echo out the image name instead of using a seperate php to fetch the image and put that in the image tag.

 

Let me elaborate that with a code sniplet.

 

If you would just store the image name inside the db you could do something like:

<img src="<?php echo $image_name;?>" />

 

If you would use a blob type you would need a separate php script to echo out the image like so:

<img src="fetch_image.php?image_id=69" />

 

Link to comment
Share on other sites

Alright first of all, you must connect to the database before anything. It has to be top priority! Second BLOBS is a binary large object which can hold a variable amount of data. You only have to store the file names of the users file. Use VARCHAR.

 

You also need to make a folder where you are going to put the file (ex: "uploads/").

 

also how many files are the users going to upload? Seems like there are several here in the script.

 

Use this beginner's tutorial

 

http://www.tizag.com/phpT/fileupload.php

 

for file uploads to get to know the basics

 

I was not aware that I needed the DB connect part of the script at the beginning, I did not think it mattered that much. In my other scripts it is first, but that never dawned on me.  I can easily put it at the beginning.  I have a folder created on my server to store all of these images.  It is in the root directory and it is named "images", of course. As for the files to upload, I am trying to get 5 images maximum, but none required with each upload. To elaborate on this a bit more. Registered users to the site can create a "brief" of their ex-boyfriend/ex-girlfriend that has some of their information, and some pics, possible. the site is www.ex-brief.com . The information entered will not be the actual information of the user, but of whomever they choose, so they enter it manually, as well as upload any pics they want, max of 5 for now.

 

I am looking at that link BTW.  Thanks for the help so far.

Link to comment
Share on other sites

I have the script written to add the info to the DB, but I am having trouble getting it to actually upload image files, and then create the necessary referrer in the DB.  This is the part that has me all worked up.

This does sound more like you're actually willing to learn instead of makeing someone write it for you which is good.

 

Do be aware that when you combine regular form fields such as text input radio's and select pulldows with a file/image upload field the validation can become tricky.

 

For example, a user forgot to fill in the email field when this is a required field. This when he did select an image for uploading in the form. After the page got submitted he will receive a message where saying "you forgot to enter your email" (or something like that). Now since the user already selected the image you would want this image to be re-selected. That is a bit tricky.

 

Concerning the Blobtype vs storing just the name of the uploaded image. What i see mostly is that an image name is being stored inside the db. That way you can just echo out the image name instead of using a seperate php to fetch the image and put that in the image tag.

 

Let me elaborate that with a code sniplet.

 

If you would just store the image name inside the db you could do something like:

<img src="<?php echo $image_name;?>" />

 

If you would use a blob type you would need a separate php script to echo out the image like so:

<img src="fetch_image.php?image_id=69" />

 

thanks for the guidance. My concern with adding images to a directory rather than as a BLOB is that I do not know, not even close, how to tell the sript to give each image its own unique name so nothing gets overwritten. I do see what you mean by it being easier to do this with a directory and a referrer, as opposed to a BLOB. As you stated, this can be complicated to get the validation right. I know that is beyond my scope, but I would LOVE to see it done right so I can put that nugget in my brain for the future..lol. I am sure with help, and some more blood/sweat/tears I can get this all to work.  Fingers crossed.

Link to comment
Share on other sites

This will take time, don't give up, keep updating us with what you got.

 

I will, I am going to try to change what I have to more closely match the multiple file uploader link you sent me, and that should get me to where these are getting uploaded to the correct folder, at least, then I will try to build on that.  thanks.  In this script, there is nothing going to the database.  I understand how this is uploading the actual images to the directory, then echoing confirmation that this is done, but where I am confused is how the image link info gets put into the database with the rest of the information submitted, such as name, city, etc.  That's the part that is confsing me I guess.

Link to comment
Share on other sites

This will take time, don't give up, keep updating us with what you got.

 

I tried that tutorial, and here is what I got for my efforts...lol.  This is going badly.

 

Warning: copy(http://www.ex-brief.com/upload/z.png) [function.copy]: failed to open stream: HTTP wrapper does not support writeable connections in /home/exbriefc/public_html/test/multiple_upload_ac.php on line 11

Link to comment
Share on other sites

We need more info in order to give usefull help.

 

What is the question just a error message isn't very helpfull.

Can you post the relevant code that causes the error.

 

actually, I have discarded that code completely, and I am trying something else. I will post when I have that going. Should be later today/tonight, thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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