Jump to content

ball420

Members
  • Posts

    141
  • Joined

  • Last visited

    Never

Everything posted by ball420

  1. I wanted to post the solution in case anyone ever needs it. What I ended up doing was creating a uniqid() and taking that unique id and changing the name in move_uploaded_file. but i needed these new unique names to be in an array so that i could INSERT into SQL. so what i did ws in my for loop everytime there was a new uniqid created i pushed it it the array. Sorry if it's confusing but you can look at my original code and compare to the working code below $number_of_file_fields = 0; $number_of_uploaded_files = 0; $number_of_moved_files = 0; $un_id =uniqid(); $uploaded_files = array(); $final_names = array(); $upload_directory = dirname(__file__) . '/car-images/'; //set upload directory /** * we get a $_FILES['images'] array , * we procee this array while iterating with simple for loop * you can check this array by print_r($_FILES['images']); */ for ($i = 0; $i < count($_FILES['images']['name']); $i++) { $number_of_file_fields++; if ($_FILES['images']['name'][$i] != '') { //check if file field empty or not $number_of_uploaded_files++; //this adds to the unique id for each item in the array $un_id++; if (move_uploaded_file($_FILES['images']['tmp_name'][$i], $upload_directory . $un_id . ".jpg")) { $number_of_moved_files++; $the_new_names = $un_id . ".jpg"; array_push($final_names, $the_new_names); } } }
  2. what I'm doing is uploading multiple images, usually a different amount each time. That works fine until I added a for loop using the rename function to get the images just uploaded and rename them. What's happening now is only the last image in the $uploaded_files array is actually being uploaded and being renamed. Am i using the wrong syntax somewhere? Thanks in advance for the replies. if (isset($_POST['Submit'])) { $number_of_file_fields = 0; $number_of_uploaded_files = 0; $number_of_moved_files = 0; $unique_Id = uniqid(); $uploaded_files = array(); $upload_directory = dirname(__file__) . '/car-images/'; //set upload directory /** * we get a $_FILES['images'] array , * we procee this array while iterating with simple for loop * you can check this array by print_r($_FILES['images']); */ for ($i = 0; $i < count($_FILES['images']['name']); $i++) { $number_of_file_fields++; if ($_FILES['images']['name'][$i] != '') { //check if file field empty or not $number_of_uploaded_files++; $uploaded_files[] = $_FILES['images']['name'][$i]; if (move_uploaded_file($_FILES['images']['tmp_name'][$i], $upload_directory . $_FILES['images']['name'][$i])) { $number_of_moved_files++; } } } ///This is the loop that's making it only upload one image and rename it. for ($i=0; $i < $number_of_uploaded_files; $i++) { rename($upload_directory . $uploaded_files[$i], $upload_directory . $unique_Id . '.jpg'); }
  3. Hey all, I'm trying to upload multiple image(which works great) but the problem I'm having is when an image is uploaded it over-rights a previous image if they are the same name and the old one is gone. Solution: create a unique name for each image before it's uploaded, change the name and then upload it. I can't seem to figure the correct syntax. My thought was to take the image name and add a random number to the front of it. Am i going about this the right way? thanks for the replies in advance. code below if (isset($_POST['Submit'])) { $number_of_file_fields = 0; $number_of_uploaded_files = 0; $number_of_moved_files = 0; //creating my random number $random_digit=rand(0000,9999); $uploaded_files = array(); $upload_directory = dirname(__file__) . '/car-images/'; //set upload directory for ($i = 0; $i < count($_FILES['images']['name']); $i++) { $number_of_file_fields++; if ($_FILES['images']['name'][$i] != '') { //check if file field empty or not $number_of_uploaded_files++; $uploaded_files[] = $_FILES['images']['name'][$i]; if (move_uploaded_file($_FILES['images']['tmp_name'][$i], $upload_directory . $_FILES['images']['name'][$i])) { $number_of_moved_files++; } } } $image0 = $uploaded_files[0]; $image1 = $uploaded_files[1]; $image2 = $uploaded_files[2]; $image3 = $uploaded_files[3]; $image4 = $uploaded_files[4];
  4. I was curious if anyone knew of what the unique picture that you enter the numbers or letters to submit a form is called. and if anyone could guide me to some good tutorials for this. thanks a mill
  5. thanks for your help i was just explaining what I thought was going on. So i guess i have it down I'm going to get it all set up I think i got it now. thanks again
  6. this is what i have, $_SESSION['mycart']= $_POST['mycart'];."item_name|"; so that I understand the session named 'mycart' will be carried from page to page given that I carry this same session on each page using <?php session_start(); $_SESSION['mycart']= $_POST['mycart'];."item_name|"; session_write_close(); ?> then each product with the the form name="item_name" will line up when each product is submitted again with the same form name="item_name" but with different values. then at the end when i want to use all the vars collected in the session i use explode. thanks for your guidance I hope I didn't sound too confusing.
  7. so when i explode at the "checkout" the session will store all the input fields from each <form> </form> that's posted? thanks for the guidance much appricated
  8. here is my issue.... i have a small shopping cart meaning 20 items, i have it set up now that when you click on an item you go to the next page and the item info shows. Here is the code from the first page <form action="page2.php" method="post"> <input type="hidden" name="item_name" value="A-07"> <input type="hidden" name="amount" value="55.00"> <input type="hidden" name="no_shipping" value="2"> <input type="image" src="SM.gif" border="0" name="submit" > <img alt="" border="0" src="pixel.gif" width="1" height="1"> </form> what i want to do is to be able to go back to the product pages but still keep that item in the "session" so when you go to the checkout page all those items are there. I understand that i will need to use sessions but how do i differentiate between items if each item has the same variables within the <form></form>? I hope I'm explaining correctly. Thanks for the guidance it's much appreciated.
  9. thanks for the help everyone this was the solution i used thanks for the guidance $result = 54.89 * .07; echo number_format ("$result", 2);
  10. I want to display the only two numbers after I multiply. example when multiplying 54.89 * .07 the answer is 3.8423 i only want to echo two numbers after the decimal. Is there a way to do this? Can somone guide me in the right direction I have tried to search google and just can't seem to find anything. thanks in advance for the guidance
  11. thanks for your help i was really struggling with it. I did solve the issue what i ended up doing was on the submit of the form it calls two different scripts one for the email and the other to enter the info into the database. I didn't fix the problem with the script but i did get it to work. thanks again for your much appricated.
  12. cool, that def makes sense. thanks for the reply i'll just have to pay attention to my file size more than i normally do. thanks again
  13. i have started building my pages with <? include ("top.inc"); ?> and all my code for the page here and then <? include ("bottom.inc"); ?> does anyone know if this takes away from SEO? thanks fro the replys!
  14. I have gotten my script to write to my sql database no problem works great. I want it then to email, I have been staring at this for hours and trying a thousand things. can someone give me some insight on what i might be doing wrong. Thanks for the help <?php $host= 'slkd'; $username= 'sd'; $password= 'm5sdd'; $db_name= 'db2sdfsdsfsdf77'; $tbl_name= 'entries'; $firstname = $_POST['firstname']; $lasttname = $_POST['lastname']; $email = $_POST['email']; $location = $_POST['location']; $age = $_POST['age']; mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $sql="INSERT INTO $tbl_name (firstname, lastname, email, location, age) VALUES ('$firstname', '$lastname', '$email','$location','$age')"; $result=mysql_query($sql) or die("query error:".mysql_error() ); if($result){ $firstname = $_POST['firstname']; $lasttname = $_POST['lastname']; $email = $_POST['email']; $location = $_POST['location']; $age = $_POST['age']; $sendTo = "ball@marley.com"; $subject = "Signup"; $sign = "Sign up"; $up = "form"; $emailer ="promotions.com"; $messager = "Someone has signed up on ations.com" $headers = "From: " . $_POST["$sign"] ." ". $_POST["$up"] . "<" . $_POST["$emailer"] .">\r\n"; $headers .= "Reply-To: " . $_POST["$emailer"] . "\r\n"; $headers .= "Return-path: " . $_POST["$emailer"]; mail($sendTo, $subject, $messager, $headers); } else { echo "ERROR"; } mysql_close(); ?>
  15. i have a flash document that when my variables are being passed to my PHP document they are emailing me with all html formats. does any know why this is happening and how to fix? thanks a million for your input!! this is really confusing the hell out of me... thanks again
  16. this is a good question but looking at koolaids code and your code i see what you have changed but am not sure why or what you exactly did. can you explain. thanks
  17. thanks man works great. learn somthing new everyday. i really appriciate it
  18. updated code <?php $newDirName = $_GET["clientsName"] $_POST["repsName"] . $_POST["clientsName"]. $_POST["clientsPhone"]. $_POST["clientsUrl"]. $_POST["shortDescroption"]. $_POST["longDescription"]; if(is_dir("./files")) mkdir("./files/"$newDirName, 0755); $mode = file_exists('user_input.txt')?'a':'w'; // append if file exists otherwise create it $fp = fopen('user_input.txt',$mode); // open file fwrite($fp,print_r($_POST,true)."\r\n"); // dump the contents of the $_POST array to the file fclose($fp); ?>
  19. that won't work becuse my name is vote the value is submit. that is working right
  20. i got it to create and write a txt file but now i'm trying to get it to create a new directory then write the file. thanks for all the help <?php $newDirName = ["clientsName"] $_POST["repsName"] . $_POST["clientsName"]. $_POST["clientsPhone"]. $_POST["clientsUrl"]. $_POST["shortDescroption"]. $_POST["longDescription"]; if(is_dir("./files")) mkdir("./files/"$newDirName, 0755); $mode = file_exists('user_input.txt')?'a':'w'; // append if file exists otherwise create it $fp = fopen('user_input.txt',$mode); // open file fwrite($fp,print_r($_POST,true)."\r\n"); // dump the contents of the $_POST array to the file fclose($fp); ?>
  21. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="600" border="0" cellpadding="0" cellspacing="0" > <!--DWLayoutTable--> <tr> <td width="15" height="16"></td> <td width="45"></td> <td width="234"></td> <td width="306"></td> </tr> <tr> <td height="143"></td> <td colspan="2" valign="top"><img src="mytime.jpg" width="308" height="154" /></td> <td> </td> </tr> <tr> <td height="58"></td> <td> </td> <td></td> <td></td> </tr> <tr> <td height="251"> </td> <td> </td> <td colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"><form id="poller" name="poller" method="post" action="mailer.php"> <!--DWLayoutTable--> <tr> <td height="19" colspan="2" valign="top">this is song number one </td> <td width="213" rowspan="20" valign="top"> <label> <input type="radio" name="song1" value="1" /> 1</label> <label> <input type="radio" name="song1" value="2" /> 2</label> <label> <input type="radio" name="song1" value="3" /> 3</label> <label> <input type="radio" name="song1" value="4" /> 4</label> <label> <input type="radio" name="song1" value="5" /> 5</label> <label> <br /> <br /> <input type="radio" name="song2" value="1" /> 1</label> <label> <input type="radio" name="song2" value="2" /> 2</label> <label> <input type="radio" name="song2" value="3" /> 3</label> <label> <input type="radio" name="song2" value="4" /> 4</label> <label> <input type="radio" name="song2" value="5" /> 5</label> <label> <br /> <br /> <input type="radio" name="song3" value="1" /> 1</label> <label> <input type="radio" name="song3" value="2" /> 2</label> <label> <input type="radio" name="song3" value="3" /> 3</label> <label> <input type="radio" name="song3" value="4" /> 4</label> <label> <input type="radio" name="song3" value="5" /> 5<br /> </label> <label> <br /> <input type="radio" name="song4" value="1" /> 1</label> <label> <input type="radio" name="song4" value="2" /> 2</label> <label> <input type="radio" name="song4" value="3" /> 3</label> <label> <input type="radio" name="song4" value="4" /> 4</label> <label> <input type="radio" name="song4" value="5" /> 5<br /> </label> <label> <br /> <input type="radio" name="song5" value="1" /> 1</label> <label> <input type="radio" name="song5" value="2" /> 2</label> <label> <input type="radio" name="song5" value="3" /> 3</label> <label> <input type="radio" name="song5" value="4" /> 4</label> <label> <input type="radio" name="song5" value="5" /> 5<br /> </label> <label> <br /> <input type="radio" name="song6" value="1" /> 1</label> <label> <input type="radio" name="song6" value="2" /> 2</label> <label> <input type="radio" name="song6" value="3" /> 3</label> <label> <input type="radio" name="song6" value="4" /> 4</label> <label> <input type="radio" name="song6" value="5" /> 5<br /> </label> <br /> <input type="radio" name="song7" value="1" /> 1 </label> <label> <input type="radio" name="song7" value="2" /> 2</label> <label> <input type="radio" name="song7" value="3" /> 3</label> <label> <input type="radio" name="song7" value="4" /> 4</label> <label> <input type="radio" name="song7" value="5" /> 5<br /> </label> <br /> <input type="radio" name="song8" value="1" /> 1 </label> <label> <input type="radio" name="song8" value="2" /> 2</label> <label> <input type="radio" name="song8" value="3" /> 3</label> <label> <input type="radio" name="song8" value="4" /> 4</label> <label> <input type="radio" name="song8" value="5" /> 5<br /> </label> <br /> <input type="radio" name="song9" value="1" /> 1 </label> <label> <input type="radio" name="song9" value="2" /> 2</label> <label> <input type="radio" name="song9" value="3" /> 3</label> <label> <input type="radio" name="song9" value="4" /> 4</label> <label> <input type="radio" name="song9" value="5" /> 5</label> <br /><br /> <input type="radio" name="song10" value="1" /> 1 </label> <label> <input type="radio" name="song10" value="2" /> 2</label> <label> <input type="radio" name="song10" value="3" /> 3</label> <label> <input type="radio" name="song10" value="4" /> 4</label> <label> <input type="radio" name="song10" value="5" /> 5</label> <br /> </td> <td width="61"></td> </tr> <tr> <td width="26" height="23"> </td> <td width="237"> </td> <td></td> </tr> <tr> <td height="19" colspan="2" valign="top">this is song 3 </td> <td></td> </tr> <tr> <td height="24"> </td> <td></td> <td></td> </tr> <tr> <td height="19" colspan="2" valign="top">this is song # 2 </td> <td></td> </tr> <tr> <td height="20"> </td> <td></td> <td></td> </tr> <tr> <td height="19" colspan="2" valign="top">this is song 3 </td> <td></td> </tr> <tr> <td height="22"> </td> <td></td> <td></td> </tr> <tr> <td height="19" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td> <td></td> </tr> <tr> <td height="22"> </td> <td></td> <td></td> </tr> <tr> <td height="19" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td> <td></td> </tr> <tr> <td height="22"> </td> <td></td> <td></td> </tr> <tr> <td height="19" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td> <td></td> </tr> <tr> <td height="22"> </td> <td></td> <td></td> </tr> <tr> <td height="19" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td> <td></td> </tr> <tr> <td height="23"> </td> <td></td> <td></td> </tr> <tr> <td height="19" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td> <td></td> </tr> <tr> <td height="21"> </td> <td></td> <td></td> </tr> <tr> <td height="19" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td> <td></td> </tr> <tr> <td height="2"></td> <td></td> <td></td> </tr> <td height="24"> </td> <td colspan="2" valign="top"><div align="center"><input name="Vote" type="submit" value="submit" /></div></td> <td> </td> </tr> </form></table></td> </tr> <tr> <td height="15"></td> <td></td> <td></td> <td></td> </tr> </table> </body> </html>
  22. it's not even creating it i'll show you how i have put it in my code. Mabey i'm not formating it right <?php if(isset($_POST['submit'])) { $errmsg = ''; // error message $nextstep = "nextstep.php"; $song1 = $_POST['song1']; $song2 = $_POST['song2']; $song3 = $_POST['song3']; $song4 = $_POST['song4']; $song5 = $_POST['song5']; $song6 = $_POST['song6']; $song7 = $_POST['song7']; $song8 = $_POST['song8']; $song9 = $_POST['song9']; $song10 = $_POST['song10']; $body = " $song1 /n $song2 /n $song3 /n $song4 /n $song5 /n $song6 /n $song7 /n $song8 /n $song9 /n $song10 /n " ; } $mode = file_exists('user_input.txt')?'a':'w'; // append if file exists otherwise create it $fp = fopen('user_input.txt',$mode); // open file fwrite($fp,print_r($_POST,true)."\r\n"); // dump the contents of the $_POST array to the file fclose($fp); header('Location: nextstep.php'); exit; ?>
×
×
  • 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.