Jump to content

paulonline2501

Members
  • Posts

    70
  • Joined

  • Last visited

Everything posted by paulonline2501

  1. hi thescientist, im not sure what you mean? i do have various SESSION variables that i set when the user logs in etc. one of which is the SESSION[id] which i use in the SQL to work out which of the user_ftps is associate to the user. select *from user_ftpswhere id = session[id] but how does this help me in terms of creating a link to the edit page with the id of the ftp i want to edit?
  2. ok, thanks. i guess then what i will do is for each result that is return from the database i will put a form in the <li> with a hidden field and just a submit button. ....actually that wont be good either because the id will be visable in the html.... ....i know what ill do. ill use 'get' [this will mean i dont have to use a lot of buttons/forms] and ill pass a token compraising user_id, ftp_id, and a random generated string [possibly encrypted]. then other users wont be able to tamper with the url. does that sound ok? can you think of any improvements???
  3. hi, so my problem is: i have a web page that produces a list [ul]. the list is the list of ftp sites that belong to a specific user in the database example: select * from user_ftps where user_id = 'x' great! that works fine. in this case i get three sites back belonging to the user. perfect. i also put a hyper link with a 'get' in the output so the user can click edit and edit the site they want. like so: if (mysql_num_rows($result) > 0) { while(list($db_id, $db_user_id, $db_name) = mysql_fetch_row($result)) { echo "<li>$db_name [<a href="ftps/edit?id=$db_id">edit</a>]</li>"; } } the problem is, using this method the user can alter the id in the url to the number of another user and see all their ftp sites. "Use Post with a hidden value" i hear you say. but if i do that i'll need to create a button for each 'edit' link. i think. not really a problem i surpose. but i want to know if there is a better way i can do this or if i'm just approching this in the wrong way and should be using a different method. regards, paul
  4. thanks dsonesuk. ive used your example, and its working well.its seems a bit of a shame though that list-style-image seems to have this bug.i say bug, because i cant really see why you would want the text to act like that.maybe im missing the point?maybe w3c could add an attribute to control this?
  5. hi everyone, im having trouble with some custom images im adding to a site.i have made a picture of a tick that i want to be display next to each li. im using the list-style-image css property to do this. the image is displaying as i would like. however, the text of the li is doing something that i dont want, when the text doesn't fit on one line. the first line will be at the top of the image, but the 2nd line will be at the bottom of the image. i want it and would expect it to appear directly under the first line. this means the list is very confusing to read with big gaps between the 1st and 2nd line of items but small gaps between 2nd line of one item and the first line of the next item. very confusing! how can i get the lines of text for each list item to appear under each other normally. the CSS code: .tick li{list-style-image: url(../_images/tick.jpg);padding:2px 2px 2px 2px;/*top, right, bottom, left*/vertical-align:top;}.tick ul{padding:2px 2px 2px 2px;/*top, right, bottom, left*/} the list code: <ul class="tick"><li>asd asdasdasdasdasdasd asd a sd as da sd as da sdasdasd aa sd as d asd a sd as d asda sd as d asd</li><li>asd asdasdasdasdasdasd asd a sd as da sd as da sdasdasd aa sd as d asd a sd as d asda sd as d asd</li><li>asd asdasdasdasdasdasd asd a sd as da sd as da sdasdasd aa sd as d asd a sd as d asda sd as d asd</li><li>asd asdasdasdasdasdasd asd a sd as da sd as da sdasdasd aa sd as d asd a sd as d asda sd as d asd</li></ul> you can see the page here. if it looks fine, ive fixed it!
  6. Great! thanks justsomeguy. both your suggestions worked, but ive gone with the array answer as it seems seems like the most sophisticated. <?php$alreadyUsedImages = array();$imagesDir = '../_images/gallery/';$images = glob('../_images/gallery/*.{jpg,jpeg,png,gif}', GLOB_BRACE);$count=0;do{ $randomImage = $images[array_rand($images)]; if(!in_array($randomImage, $alreadyUsedImages)) { $count++; echo "<img src=\"$randomImage\" alt\"\" />"; $alreadyUsedImages[$count] = $randomImage; //echo("false"); } else{ //echo("true"); }}while ($count<=3);?>
  7. hi, im trying to show three random pics from a folder and make sure the same pic dosnt get shown more than once. ive got it picking a random pic, but for some reason pics that i add to my $alreadyUsedImages variable are being displayed. the strpos seems to working as i tested by putting echos for true or false in there [not in code shown], i think its something to do with the strpos not working correctly!!sometimes images show up even when they've been displayed. it doesnt seem the strpos is getting consistent matches.this may have something to do with the $randomImage including the path with forward slashes. <table class="gallery"><?php$alreadyUsedImages = "";$imagesDir = '../_images/gallery/';$images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE); $c=1;do{ $randomImage = $images[array_rand($images)]; if(strpos($alreadyUsedImages, $randomImage)==false) { $c++; echo "<tr><td><img src=\"$randomImage\" alt\"\" /></td></tr>"; $alreadyUsedImages .= $randomImage; }else}while ($c<=3);?></table>
  8. Dates are stored in a different format in databases. You need to change the format.See here:http://php.net/manual/en/function.date.php
  9. You can display connection error like so:. mysql_error() Append it to you current error message
  10. ive run all these echos and they result in blank values, wether i chose a file or not. echo"</br>userfile = ";echo(($_POST['userfile']));echo"</br>pic = ";echo(($_POST['pic']));echo"</br>userfile = ";echo(($_POST[userfile]));if (!isset($_POST[userfile])) { echo"pic not filled in";}if (isset($_POST[userfile])) { echo"pic filled in";}//end of check to see if picture has been filled in
  11. hi all, i have an 'edit item page'.its for people to edit items in the database.when the chose an item to edit they get taken to a web page with a form on it.the form is filled with the current values in the database - apart from the picture field.i have left that balnk on perpose as im presuming they are happy with the pic.if they dont chose a new file and press save the details in the form [apart from the picture] update with the new values.if however they want to changer the pic and browse for a file i want this new pic to upload. therefore what im trying to do is do a check to see if the pic field has been filled in.if is has then run the upload file function.if the pic field has not been filled in then dont run the upload logic and only update the otther fields. im getting stuck where im doing the check. ive tried a bunch of things but they dont seem to work.my closest was as follows: if (!isset($_POST['pic'])) { echo"pic not filled in";}if (isset($_POST['pic'])) { echo"pic filled in";}//end of check to see if picture has been filled in ...it always returns: 'not filled in' CUT DOWN VERSION OF FULL SCRIPT <?php//set current item ID$currentItemID = htmlspecialchars($_GET["id"]);// Setup defaults.$error = 0; //input errors$up_error = 0; //title and description error counter - used to only show error message once.$clean = array();$clean_name = "";$clean_description = "";$clean_price = "";$clean_pic = "";$clean_status = "";$clean_quantity = "";//if all input is valid then...if (isset($_POST['add'])){ if (!isset($_POST['pic'])) { echo"pic not filled in";}if (isset($_POST['pic'])) { echo"pic filled in";}//end of check to see if picture has been filled in }else{ /////////render form?><form enctype="multipart/form-data" action="" method="post" id="save"><fieldset><table id="site-form"><tr><td class="one_of_three"><label>Item Name: </label></td><td class="two_of_three"><input type="text" name="fileName" id="fileName" value="<?php echo"$db_name";?>"/></td><td><label class="errors" id="fileNameError"> </label></td></tr> <tr><td class="one_of_three"><label>Picture: </label></td><td class="two_of_three"><input type="file" name="userfile[]" id="pic"/></td><td><label class="errors" id="picError"> </label></td></tr> <tr> <td class="one_of_three"> </td> <td class="two_of_three"><input name="add" id="save_button" type="submit" value="Update"/> <a href="../">Cancel</a>.</td> <td> </td></tr></table></fieldset></form><?php }?>
  12. ....ok, thanks. i think i'll just post to another page and have the 2nd button on the 2nd page. this would keep it on the server.
  13. hi, should be a straight forwrd answer for this one.is it possible to post twice to the same page? eg: you want the person to select an item from a drop down list, click a button to submit their choose (post #1), and then do something else like update the details of the item and then submit again (post #2). i mean i could go to a different page with the post#1 id after the first post, but i was wondering if i could do it all on the same page? i've had a stab at doing this and the code is below but when i click the 2nd post button it resets the whole page. ive got a sneaky recolection that this normal as this isnt possible but cant quite remember. any help would be great. CODE: <?phpif (isset($_POST['post1'])){echo"Form 1 has been submitted.";/**********post 2*******************************/ if (isset($_POST['post2'])) { echo"Form 2 has been submitted."; } else { //render form 2 ?> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="form2"><fieldset> <table id="site-form"> <tr> <td class="one_of_three"> </td> <td class="two_of_three"><input name="post2" id="post2" type="submit" value="Click Me (2)"/> <a href="">Cancel</a>.</td> <td> </td> </tr> </table> </fieldset></form> <?php }/********** end post 2*******************************/}else {//render form 1?><form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="form1"><fieldset><table id="site-form"><tr> <td class="one_of_three"> </td> <td class="two_of_three"><input name="post1" id="post1" type="submit" value="Click Me (1)"/> <a href="">Cancel</a>.</td> <td> </td></tr></table></fieldset></form><?php}?> if you want to see whats happening its here:http://paulyouthed.c...p-two-posts.php
  14. thats great!!!!!!!!! thanks a lot guys. so for any one who wants to see the code that worked (slightly changed from the original to be simpler to understand) here it is: <?php//has form been submitted???if (isset($_POST['submission'])){ //render title and open list echo"<h2>Music you like</h2><ul>"; //check for checked boxes if (isset($_POST['questionaire']) && is_array($_POST['questionaire'])) { //for each item checked do the following foreach ($_POST['questionaire'] as $answer) { //render name of item checked echo"<li>$answer</li>"; } } //if nothing is checked render this: else{echo"<li>You dont like any of the options.</li>";} //close list echo"</ul>";} //render formelse{?> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="save"><fieldset> <p>Do you like Northern Soul?<input type="checkbox" name="questionaire[]" value="northern" /></p> <p>Do you like the blues?<input type="checkbox" name="questionaire[]" value="blues" /></p> <p><input type="submit" name="submission" value="Submit"/> <a href="">Cancel</a>.</p> </fieldset></form><?php}?> if you want to try the form go here:http://paulyouthed.c...using-array.php thanks again, paul
  15. hi, ive simpilified my code so i can get my head around whats going on here because i dont understand: how the array is being populated how to get the results to show up. the code is much simplier now (not using a variable any more). <?php//has form been submitted???if (isset($_POST['submission'])){if (isset($_POST['questionaire'])){foreach($_POST['delete_pictures[]'] as $key){echo $key;}}} //render formelse{?><form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="save"><fieldset><p>Do you like Northern Soul?<input type="checkbox" name="questionaire[]" value="northern" /></p><p>Do you like the blues?<input type="checkbox" name="questionaire[]" value="blues" /></p><p><input type="submit" name="submission" value="Submit"/> <a href="">Cancel</a>.</p></fieldset></form><?php}?> P.S. probably not that relevant as its a PHP page but im testing the code here
  16. ....i tried the code below. i dont get any error but the test echo doesnt display anything. <?php // Setup defaults.$error = 0; //input errors$up_error = 0; //title and description error counter - used to only show error message once. //set up pictures array$pictures = array();//$delete_pictures = array(); //if all input is valid then...if (isset($_POST['delete'])) {//clear error message$errmsg = ''; if (isset($_POST['delete_pictures[]'])) {$_POST['delete_pictures[]'] = isset($_POST['delete_pictures[]']) ? $_POST['delete_pictures[]'] : ''; echo($_POST['delete_pictures[]']);//$file_to_delete = "../../_pics/about/$_POST['delete_pictures[]']";//unlink($file_to_delete)} } else //output error messages {if ($error>0) {echo "<p><strong>There were errors in your submission:</strong> $errmsg</p>\n";}//render form?><form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="save"><fieldset><table id="site-form"><?php//reset counter$counter = 0; //render pictures in the relavent folderforeach (glob('../../_pics/about/*.jpg') as $file){//strip down full path to file name$file = basename($file);//set value of array$pictures[$counter] = $file;//output table row for current pictureecho"<tr><td>File: $pictures[$counter]</td><td> <a href=\"../../_pics/about/$pictures[$counter]\"> <img src=\"../../_pics/about/$pictures[$counter]\"></a></td><td><input type=\"checkbox\" name=\"delete_pitures[]\" value=\"$pictures[$counter]\" /></td></tr>";$counter++;}?><tr><td colspan="3"><input name="delete" id="save_button" type="submit" value="Delete Picture(s)"/> <a href="../">Cancel</a>.</td></tr></table></fieldset></form><?php//testecho"$pictures[0]";}?>
  17. ...a few more questions. 1.do i need to declare the 'delete_pictures[]' 2.how do i call the post???like this?: if (isset($_POST['delete_pictures[]'])) {$_POST['delete_pictures[]'] = isset($_POST['delete_pictures[]']) ? $_POST['delete_pictures[]'] : ''; $file_to_delete = "../../_pics/about/$_POST['delete_pictures[]']"; unlink($file_to_delete)} 3.when you said i was using single quotes incorrectly what variable where you reffring too?
  18. hi everyone, outline:i have a web page that displays a lists of pictures from a certain folder, with a check box next to each picture.i want to allow the user to check the box next to the picture they want to delete, and then when the press the 'delete' button all those pics get deleted. ive got the page displaying the pics and the checkboxes fine, im even putting the name of each picture into an array for later - thats no problem. however, when i go back to the on submit section of the script the array name is not being remembered by the page and i can t even get the array value to 'echo' on to the page (just as a test). therefore i cant make any progress with the deletion process. any help on how i can get the array to work outside of the 'for each' loop would be great. my code is as follows: <?php// Setup defaults.$error = 0; //input errors$up_error = 0; //title and description error counter - used to only show error message once. //set up pictures array$pictures = array(); //if all input is valid then...if (isset($_POST['delete'])){//clear error message$errmsg = ''; //set up post data from form for each pic/*foreach (glob('../../_pics/about/*.jpg') as $file){$file = basename($file);$_POST['$file'] = isset($_POST['$file']) ? $_POST['$file'] : '';}*/}if (isset($_POST['delete']) && ($error==0)){//reset picture_counter$picture_counter = 0; //this echo test does NOT work!!!!!!!!!!!!!!!!echo"$pictures[0]"; //sleep(6); //$_POST['$pictures[$picture_counter]'] = isset($_POST['$pictures[$picture_counter]']) ? $_POST['$pictures[$picture_counter]'] : ''; /***************************************************** IGNORE THIS CODE FOR NOWif(isset($_POST['$pictures[$picture_counter]'])){ echo"its checked"; $file_to_delete = "../../_pics/about/myfile.txt"; if(unlink($file_to_delete)) {echo"<p>File(s) deleted.</p>";} else {echo"<p>File(s) not deleted. <a href=\"../\">Back to Control Panel</a></p>";} }else{ echo"<p>....its not checked!!!!</p>"; echo($pictures[$picture_counter]);}******************************************************************************/}else //output error messages{if ($error>0) {echo "<p><strong>There were errors in your submission:</strong> $errmsg</p>\n";}//render form?><form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="save"><fieldset><table id="site-form"><?php//reset counter$counter = 0; //render pictures in the relavent folderforeach (glob('../../_pics/about/*.jpg') as $file){//$cleaned_up_file_name = str_replace('../../_pics/about/','',$file);//strip down full path to file name$file = basename($file);//set value of array$pictures[$counter] = $file;//output table row for current pictureecho"<tr> <td>File: $pictures[$counter]</td> <td> <a href=\"../../_pics/about/$pictures[$counter]\"> <img src=\"../../_pics/about/$pictures[$counter]\"> </a> </td> <td><input type=\"checkbox\" name=\"$pictures[$counter]\" value=\"$pictures[$counter]\" /></td></tr>";$counter++;}?><tr> <td colspan="3"><input name="delete" id="save_button" type="submit" value="Delete Picture(s)"/> <a href="../">Cancel</a>.</td></tr></table></fieldset></form><?php//this test echo DOES work.echo"$pictures[0]";}?>
  19. Outstanding dsonesuk!!! A note for any one whos interested: i just tried in IE7, Crome, Safari and my iphone- no problems at all. (much better than an image hack!)
  20. hi dsonesuk, ive tried to get your solution to work, but your writing is not easy to read just at the key point where your explaing putting the div inside another dummy div. can you explain again? this is what ive tried so far, but my text is transparent [which i dont want] aswell as the background. .header{background:#CCC;}.header{opacity:0.6; filter:alpha(opacity=60);}.header h1{opacity:1.0; filter:alpha(opacity=100);}<body><div class="container"> <div class="header"><h1>Header</h1></div> <div class="content"> <p>some example text....</p> <p>some example text....</p> <p>some example text....</p> <p>some example text....</p> </div></div></body>
  21. ...thanks, but ive tried that already. unfortunatly that method will make the text aswell as the background of the DIV transparent.this is not an acceptable solution.only the background should be transparent - the text should be unaffected.
  22. hello everyone, im trying to get a div to be 50% transparent.i can get it to be 100% transparent by using the code below, but i want it to be only 50% transparent. works for 100% transparency: .header{background-color:#CCC;background: transparent;} doesnt work for 50% transparency: .header{background-color:#CCC;background: transparent 50%;} any recommendations?? the header in the example should be 50% transparent http://www.paulyouth...slucent-div.php best wishes, paulY
×
×
  • Create New...