Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. http://www.php.net/manual/en/features.file-upload.php explains you how to upload files and restrict them. use copy() to rename the uploaded file to the username's name: http://be.php.net/manual/en/function.copy.php Here you go
  2. 1) read the manual 2) come back if you have a php problem
  3. ignace

    search

    Post your db scheme
  4. Where does $res and $count come from? <?php function doIt($it) { switch ($it) { case '$count'://i want to use a counter and increment the counter each time through while($row=mysql_fetch_array($res)){//i want to use a wile loop this does not work return "<div style=\"width: 100px; height: 84px; text-align: center; float: left;\"><img src=\"images/pokemon_sprites/001.png\" width=\"100\" height=\"100\" /></div><div style=\"overflow: hidden; width: 100px; float: left; padding-top: 32px; line-height: normal;\"><strong>Bulbasaur</strong><br><span class=\"smallVerdana\">Level 1<br /><div class=\"clear\"><img src=\"battle_files/spacer.gif\" alt=\"sp\"></div> <div style=\"width: 100px; text-align: left;\"> <div class=\"hpBar\" style=\"width: 100%;\"><img src=\"battle_files/spacer.gif\" alt=\"sp\" style=\"height: 12px;\"></div>45/45 Hit Points<br /><div class=\"clear\"><img src=\"battle_files/spacer.gif\" alt=\"sp\"></div></div>";//'.$i[iD].'. } break; } } ?>
  5. Please provide a short summary (table names + columns) of all relevant tables
  6. <?php $select = 'SELECT * FROM clients'; $where = ''; if (!empty($_POST['email_address'])) { $emailAddress = $_POST['email_address']; // don't forget to validate and filter $where .= " email_address = '$emailAddress' OR email_address LIKE \'%$emailAddress%\'"; } if (!empty($_POST['phone_number'])) { .. $select .= "WHERE $where"; ?>
  7. Apparently I was wrong. fopen() does not get disabled but gets limited, to be more precise: A full listing can be found here: http://www.php.net/manual/en/features.safe-mode.functions.php
  8. <?php if (empty($_GET['id'])) { //?id= does not exist, what to do? } $id = (int) $_GET['id']; $query = 'SELECT * FROM contents WHERE id = %u'; $fquery = sprintf($query, $id); $result = mysql_query($fquery, $db); $row = mysql_fetch_assoc($result); //work with $row print $row['title']; print $row['excerpt']; ?>
  9. $row[nl2br('Comment')] Would be less clever You probably mean: nl2br($row['Comment']) And yes you could do that
  10. Then it would still work $putanja = "../files/naslovi/" . $_GET['id'] . "/" . $photo['filename'] . ".txt"; print basename($putanja); //$photo['filename'].txt
  11. We are a help forum, so we are always gentle unless you ask us things that are already covered in the manual because those who wrote it deserve the respect. Add this to your query: LIMIT 1 I'm in a good mood today
  12. ignace

    PHP mail

    modify your checkboxes name to: <input type="checkbox" name="ch[]" value="jobfunction1"> <input type="checkbox" name="ch[]" value="jobfunction2"> <input type="checkbox" name="ch[]" value="jobfunction3"> <input type="checkbox" name="ch[]" value="jobfunct..."> Then in your php you can do: $JobFunction = implode(', ', $_POST['ch']); // jobfunction1, jobfunction2, ..., jobfunction13 (no trailing ,) The same goes for $business, $owner, $human, .. Assume a common name: occupation Business: <input type="radio" name="occupation[]" value="1"><!-- if checked then the value=1, null otherwise --> Owner: <input type="radio" name="occupation[]" value="1"> Human: <input type="radio" name="occupation[]" value="1"> <?php $occupation = $_POST['occupation']; //array('1', '', '', '1', '', '', '', '1', ..); array_walk($occupation, 'set_bool'); $occupation = implode(', ', $occupation); // 1,0,0,1,0,0,0,1, .. function set_bool(&$item, $key) { $item = !empty($item) ? 1 : 0; } ?>
  13. <?php print basename($_SERVER['SCRIPT_NAME']); ?>
  14. <?php $filesource = implode(DIRECTORY_SEPARATOR, array($fromdir, $file)); $filedestination = implode(DIRECTORY_SEPARATOR, array($todir, $file)); copy($filesource, $filedestination); ?>
  15. You need a new page, then when a user wants to edit a certain image: <input type="hidden" name="filename" value="<?php print $photo['filename']; ?>"> <input type="hidden" name="action" value="update_image"> <input type="text" name="caption" value="<?php print $photo['caption']; ?>"> And add this php code: <?php if (!empty($_POST['action']) && $_POST['action'] === 'update_image') { $id = $_GET['id']; $filename = $_POST['filename']; $caption = $_POST['caption']; $filelocation = "../files/naslovi/$id/$filename.txt"; $fh = fopen($filelocation, 'w'); if ($fh) { fwrite($caption); fclose($fh); } } ?>
  16. if (empty($_SESSION['username'])) { header('location: index.php'); } else { // directly implies $_SESSION['username'] is not empty (if it was this wouldn't execute) if ((!empty ($_SESSION['username'])) && ($_SESSION['admin'] == '0') && ($_SESSION['status'] == '1')) if ((!empty ($_SESSION['username'])) && ($_SESSION['admin'] == '0') && ($_SESSION['status'] == '1')) if ((!empty ($_SESSION['username'])) && ($_SESSION['admin'] == '0') && ($_SESSION['status'] == '0')) if ((!empty ($_SESSION['username'])) && ($_SESSION['admin'] == '1')) Can be simplified to: if (!empty($_SESSION['username'])) { if (!$_SESSION['admin']) {// !0 = true if (!$_SESSION['status']) {// status=0 header('Location: index.php'); } else {// status=1 header('Location: userInbox.php'); } } else {// admin=1 include('topHalf.php'); echo ''; } } else {// $_SESSION['username']=empty header('Location: index.php'); } Which can be directly transformed to: if (empty($_SESSION['username']) || ($_SESSION['admin'] == FALSE && $_SESSION['status'] == FALSE)) { header('Location: index.php'); } if ($_SESSION['admin'] == FALSE && $_SESSION['status'] == TRUE) { header('Location: userInbox.php'); } if ($_SESSION['admin'] == TRUE) { include('topHalf.php'); echo ''; } This should help you simplify your script and will make it easier to spot errors more easily. To simplify it further, you'd get: if (empty($_SESSION['username']) || (empty($_SESSION['admin']) && empty($_SESSION['status']))) { header('Location: index.php'); } if (empty($_SESSION['admin']) && $_SESSION['status'] == TRUE) { header('Location: userInbox.php'); } if ($_SESSION['admin'] == TRUE) { include('topHalf.php'); echo ''; }
  17. Add this: <input name="quantity" type="text" value="<? echo $stringData;?>"/> To this: <form method="post" enctype="multipart/form-data" class="edit"> <h2 class="fieldset-title">Upload nove slike</h2> <fieldset> <input type="file" name="photo" /> <input type="hidden" name="page" value="<?php echo $_GET['page']; ?>" /> <input type="hidden" name="id" value="<?php echo $_GET['id']; ?>" /> <input type="hidden" name="action" value="add_photo" /> <input type="hidden" name="action" value="add_photo" /> <input type="submit" name="submit" value="Dodaj" /> </fieldset> </form> Change: if (file_exists($ourFileName)) { } else { $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); } To: if (!empty($_POST['quantity'])) { $quantity = $_POST['quantity']; $ourFileHandle = fopen($ourFileName, 'w'); if ($ourFileHandle) { fwrite($fh, $quantity); fclose($ourFileHandle); } }
  18. It is still there. Check your html to verify it, however html doesn't recognize \n therefor it is up to you to format it properly. <?php print nl2br("Hello all,\nI have the following\nA dog,\nA Cat"); ?>
  19. Stop asking these kind of questions, the most don't even respond to them because they are addressed in the manual: http://be2.php.net/manual/en/ref.filesystem.php
  20. Although not sure i think this might pull it off. SELECT * FROM members m WHERE week(m.signup_date, 1) = week(now(), 1) - 1 It's up to your implementation to display it for each and every day. Please note that for mysql the week starts on sunday. Edit: I modified the code now it starts on monday.
  21. -- Signups today SELECT count(*) as todays_new_members FROM members m WHERE m.signup_date = NOW() -- Signups this month SELECT count(*) as new_members_this_month FROM members m WHERE month(m.signup_date) = month(now()) -- Signups this year SELECT count(*) as new_members_this_year FROM members m WHERE year(m.signup_date) = year(now()) -- Total signups SELECT count(*) as total_registrations FROM members There are probably better (more performant) solutions. My 666th Post
  22. Weird, this should work however it may be an encoding kind of thing.
  23. $filename = "../files/naslovi/" . $_GET['id']; .. mkdir("../files/naslovi/" . $_GET['id'], 0777); Assume i would pass this to your script: ?id=../../badassdirectory $filename = "../files/naslovi/../../badassdirectory"; // i.e. ../badassdirectory mkdir("../files/naslovi/../../badassdirectory", 0777); You now have an additional directory (possibly) in your root. P.S. Use proper indentiation it makes your code readable
  24. <?php $fromdir = '/path/to/directory'; $todir = '/path/to/new/directory'; $files = scandir($fromdir); foreach ($files as $file) { if ($file[0] !== '.') { // escapes ., .. and files starting with a . (mostly hidden files) $filesource = implode(DIRECTORY_SEPARATOR, array($fromdir, $file)); $filedestination = implode(DIRECTORY_SEPARATOR, array($todir, $file)); copy($filesource, $filedestination); } }
  25. This produces this output: ...
×
×
  • 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.