Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. Show some code, this isn't my area, but other people could help, but you might want to give them something to go by.
  2. For one not many people will with you being rude.  You need to learn some respect before asking questions. What kind of tutorial do you mean, mime is what it's all about, I fought for 2 months with file uploading.  You have to get the file is uploaded, only means it is put in temporary memory, after htat you have to check if it was uploaded or not, if it exists, then move it, then whatever else you want to do with it then, rename it, database information ex cetera, like this. [code]<?php $management = true; $errorhandler = ""; $filemanager = true; $dateinfo = strtotime("now"); $dateformatted = date("n-d-y", $dateinfo); if ($_POST['name'] == "") { $errorhandler .= "The Name field has been left blank<br />"; } if ($_POST['keywords'] == "") { $errorhandler .= "The Keywords were left blank<br />"; } if(!is_uploaded_file($_FILES['file']['tmp_name'])){ $errorhandler .= "No file has been uploaded<br />"; $filemanager = false; } if ($filemanager === true) { $_accepted_extensions = array('.tiff', '.png', '.mpeg', '.mpg', '.wav', '.avi', '.mid', '.jpg', '.txt', '.gif', '.mp3', '.jpeg', '.gif', '.swf', '.swc', '.flv', '.mov', '.ram', '.rm', '.ra', '.rpm', '.asf', '.wma', '.wmv', '.wm', '.asf', '.wma', '.wm', '.avi', '.mpeg', '.mpg', '.mp2', '.mp3', '.mid', '.midi', '.wav');   if ($filemanager == true) { $tmp = pathinfo($_FILES['file']['name']); if (in_array('.' . $tmp['extension'],$_accepted_extensions)) { $filemanager = true; $management = true; }else { $filemanager = false; $management = false; $errorhandler .= "You have attempted to upload the wrong file type<br />"; $errorhandler .= "We only accept mpeg, mpg, wav, avi, mid, jpg<br />"; $errorhandler .= "jpeg, pdf, txt, gif, and mp3 formats<br />"; $errorhandler .= "To request new file types email<br />"; $errorhandler .= "information@theyellowpagesnetwork.com"; } } } // Relative URL with desired folder name and the name of the file on the user's machine if ($management === true && $filemanager === true) { $newfile = "uploads/".basename($_FILES['file']['name']); $newfiletemp = "{$_FILES[file][tmp_name]}"; if (file_exists($newfile)) { $errorhandler .= "The file already exists"; $filemanager = false; } if($filemanager === true) { if (!move_uploaded_file($newfiletemp, $newfile)) { $errorhandler .= "The file was not moved properly"; $filemanager = false; $manager = false; } } } if ($filemanager === true || $manager === true) { $connect = mysql_connect("localhost", "#####", "#####"); $select = mysql_select_db("funnyemailforwards"); if (!$connect && !$select) { $errorhandler .= "The database could not connect, or selected"; $management = false; $filemanager = false; }   } if ($filemanager === true && $management === true) { $query = "SELECT * from fileinfo WHERE type = '" . implode("", $_POST['type']) . "' AND nameoffunny = '" . mysql_real_escape_string($_POST['name']) . "' AND keywords = '" . mysql_real_escape_string($_POST['keywords']) . "' AND funnyurl = '" . mysql_real_escape_string($newfile) . "' AND entrydate = '" . mysql_real_escape_string($dateinfo) . "'"; $result = mysql_query($query); $matches = mysql_num_rows($result); if ($matches == 0) { $name = $_POST['name']; $name = strtolower($name); $name = str_replace(" ", "", $name); $inserter = "INSERT INTO fileinfo (type, nameoffunny, keywords, funnyurl, entrydate) VALUES ('" . implode("", $_POST['type']) . "', '" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($_POST['keywords']) . "', '" . mysql_real_escape_string($newfile) . "', '" . mysql_real_escape_string($dateinfo) . "')"; if(mysql_query($inserter)){ $management = true; $filemanager = true; }else { $management = false; $filemanager = false; $errorhandler .= "The information was not inserted into the database properly"; echo mysql_error(); } } else { $filemanager = false; $managment = false; $errorhandler .= "The information was already in the database, could not complete"; } } if ($management === false || $filemanager === false) { echo "{$errorhandler}"; } else{ echo "Everything worked out smoothly"; } ?>[/code] That right there handled the entire process for me, and I am still working on this script, I ahve to set up something to allow it to change the filename if they name it the same thing 2 times, and some otehr small functionality but this should give you the general idea.
  3. Create a form with the right fields, and query the database, and give us something to look at.
  4. The function isn't set use something like if (is_function($getFileExtension)) { echo "This is a function"; }else { echo "This is not a function"; } try this out for a test first, find out if the function even exists. If that turns out else, then something is wrong, if the function exists, then make sure it's included properly if it's in an extra page.
  5. I find extract easier to use than $row['0'] or $row['variablename'] I think it's easier just using extract($row) in most situations
  6. I am look, here The funny email like this $funnyurl = "db variable" I extracted, w hen you extract you get access to db rows, by variable name. When I access $funnyurl, I pull what is in the db, I have in the database the uploads/filename.ext For every one then I append what I need to for instance accessing the file I use $site = "http://www.funnyemailforwards.com/apex/"; Then $fullurl = $site . $funnyurl; If I echo that the url from funnyurl is pulled from the database, based on that item and it is put together with site, and it looks like this output http://www.funnyemailforwards.com/apex/uploads/filename.ext For this example, I have the $funnyurl, it has acecss to the db like usual the other thing is set like this $funnyurl = "../apex/" . $funnyurl; What that does is it points out of the directory my script is in, into apex and the file location, I know it's right there because if I use just 1 time, if I just delete 1 entry, it deletes it properly, the problem is, it won't do more than 1 at a time, how do I set it up to do all the entries. I know that the $funnyurl is being pulled from the db, I just modify it with whatever additional information per script I need to gain file access. See what I mean, any advice. Or did you mean something else when you said that, I know you said it 4 times, but I already had it set, unless you are referring to something I am not understanding.
  7. I have a script here, that does multiple things, all issues are worked out except one, it only deletes 1 file, and not the rest, I don't have any idea what I am doing wrong.  First I have a page that calls the information from a database, and displays it based on what I want. Administration page [code]<?php  // Connects to database $connect = mysql_connect("localhost", "######", "######"); $select = mysql_select_db("funnyemailforwards"); $errorhandler = ""; $management = true; if (!$connect || !$select) { $errorhandler = "The database could not connect, or was not selected<br />"; $management = false; } ?> <!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>Approval</title> </head> <body> <h3>Welcome Bobby</h3> <p>These are recently pending database entries, please accept/decline.  Please note declined entries are automatically permanently deleted from the database. These are all updated together, upon submit.  The ones that are approved are set to approved status, the ones that are declined, are immediately deleted from the database, and the file is removed from it's location on the server.  If you check some of the choice, and leave some of the choice alone, they will still be here later, for instance if there are 3 items listed.  If you approve 1, decline 1, and leave the other alone for now, the approved one is updated, the declined one is deleted, and the one left alone, is not touched, and left there, for you to update later.</p> <?php // script to display information echo "<form name=\"dataupdating\" action=\"approvalprocessor.php\" method=\"post\">"; $result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC"); while ($row = mysql_fetch_array($result)) { extract($row); $entrydate = "m/d/y"; $website = "http://www.funnyemailforwards.com/apex/"; $site = $website . $funnyurl; echo "<ul>"; echo "<li><a href=" . '"' . $site . '"' . 'target="_blank">' . $nameoffunny . "</a></li>"; echo "<li>" . $date . "</li>"; echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"1\">Approve</li>"; echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"0\">Decline</li>"; echo "</ul>";  $manager = true; } if ($manager === true) { echo "<input name=\"update\" type=\"submit\" value=\"Update Database\">"; echo "</form>"; } ?> </body> </html>[/code] Processor Page [code]<?php include 'general.inc.php'; ?> <?php if (isset($_POST['update'])) {       foreach ($_POST['approval'] as $key => $value) {     if ($value) { mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key); echo "Update Successful, update";     } else { mysql_query('DELETE FROM fileinfo WHERE id='.$key); echo "Update Successful, delete from db"; $funnyurl = "../apex/" . $funnyurl; unlink($funnyurl); // url is set to exactly like this // http://www.funnyemailforwards.com/apex/uploads/filename.ext // Follows a path exactly to the file.     } }// closes foreach }// closes isset control structure ?>[/code] Include for the processor page [code]<?php  // Connects to database $connect = mysql_connect("localhost", "#####", "#####"); $select = mysql_select_db("funnyemailforwards"); $errorhandler = ""; $management = true; if (!$connect || !$select) { $errorhandler = "The database could not connect, or was not selected<br />"; $management = false; } ?> <?php $result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC"); $row = mysql_fetch_array($result); extract($row); ?>[/code] What is currently happening that I don't want it to, is I finally got it deleting the proper file, if there is one thing to delete, but if I try to delete 2 or more items from the database, it tells me the following. something along the lines of Update Successful, delete from dbUpdate Successful, delete from db Warning: unlink(../apex/../apex/uploads/websitereport.txt): No such file or directory in /home/all/funnyemailforwards/public_html/administration/approvalprocessor.php on line 16 I don't understand why, I think it deletes a file, then tries to delete the same file a second time, I know I have a slight miscalculation somewhere but can't figure out where any advice?
  8. Sounds good, I just ran the connect, and select statement, and extract in a include, and included it in both, so I can freely use variables in both scripts from the database.
  9. Preg match or ereg can be used interchangeably, it just has different syntax rules, one is based on Perl regular expressions hte other is based on post ix(?) I think it is One is better than the other, pregmatch statistically is better and has more performance. But ereg is good for small things, like checking emails, or whatever, and I think pregmatch has slightly harder to understand syntax, but it's better overall, atleast by what I have studied
  10. [code]$regex = "^[A-Za-z0-9\._-]+@([A-Za-z0-9][A-Za-z0-9-]{1,62})(\.[A-Za-z][A-Za-z0-9-]{1,62})+$";[/code] Make that a variable that can be accessed by the script then pass this into the script [code]if (!ereg("$regex", $_POST['email'])) { //tests emails format with regex variable above $errorhandler .= "The email address is improperly formatted<br />"; }[/code] The $_POST['email'] will be the name of your variable. The errorhandler is what I use to record the errors but handle them however you want the important part is if (!ereg( and the rest of it until )) { That is the most important if the email is not formatted like something@something.com then it returns false/
  11. Ah so that would be the way also to access stock exchange information from someone's server, when they have a free service, like if someone asked me to get updated stock exchange information, I could just access there website, through a script like that.  Thanks.
  12. I am trying to pass a db variable from one script to the next but nothing is working. Admin page [code]<!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>Approval</title> </head> <body> <h3>Welcome Bobby</h3> <p>These are recently pending database entries, please accept/decline.  Please note declined entries are automatically permanently deleted from the database. These are all updated together, upon submit.  The ones that are approved are set to approved status, the ones that are declined, are immediately deleted from the database, and the file is removed from it's location on the server.  If you check some of the choice, and leave some of the choice alone, they will still be here later, for instance if there are 3 items listed.  If you approve 1, decline 1, and leave the other alone for now, the approved one is updated, the declined one is deleted, and the one left alone, is not touched, and left there, for you to update later.</p> <?php  // Connects to database $connect = mysql_connect("localhost", "#####", "#####"); $select = mysql_select_db("funnyemailforwards"); $errorhandler = ""; $management = true; if (!$connect || !$select) { $errorhandler = "The database could not connect, or was not selected<br />"; $management = false; } ?> <?php // script to display information $result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC"); echo "<form name=\"dataupdating\" action=\"approvalprocessor.php\" method=\"post\">"; while ($row = mysql_fetch_assoc($result)) { extract($row); $date = date("m/d/y"); $website = "http://www.funnyemailforwards.com/apex/"; $site = $website . $funnyurl; echo "<ul>"; echo "<li><a href=" . '"' . $site . '"' . 'target="_blank">' . $nameoffunny . "</a></li>"; echo "<li>" . $date . "</li>"; echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"1\">Approve</li>"; echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"0\">Decline</li>"; echo "</ul>";  $manager = true; } if ($manager === true) { echo "<input name=\"funny\" type=\"hidden\" value=\"{$funnyurl}\" />"; echo "<input name=\"update\" type=\"submit\" value=\"Update Database\">"; echo "</form>"; } ?> </body> </html>[/code] Here is my processor page [code]<?php  // Connects to database $connect = mysql_connect("localhost", "#####", "#####"); $select = mysql_select_db("funnyemailforwards"); $errorhandler = ""; $management = true; if (!$connect || !$select) { $errorhandler = "The database could not connect, or was not selected<br />"; $management = false; } ?> <?php if (isset($_POST['update'])) {       foreach ($_POST['approval'] as $key => $value) {     if ($value) { mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key); echo "Update Successful, update";     } else { mysql_query('DELETE FROM fileinfo WHERE id='.$key); echo "Update Successful, delete from db"; echo "{$funnyurl}"; unlink($funnyurl); // url is set to exactly like this // http://www.funnyemailforwards.com/apex/uploads/filename.ext // Follows a path exactly to the file.     } }// closes foreach }// closes isset control structure ?>[/code] I am having a few issues, I am trying to pass the variable $funnyurl over to the other page.  I originally thought it did it automatically, but I soon realized I have to use hidden form fields or something similar. I understand that, but not's why it'sn ot passing the variable even through hidden form field. THe variable is being pulled from the db, with the use of the extract function.  As well the variable has been tested, and it works, the approval pages, displays information using the $funnyurl variable, In the db the $funnyurl is set to uploads/filename.ext This allows for the quick part of the file, in my scripts, I have another variable $site = "http://www.funnyemailforwards.com/apex"; Which is the direcotry then I put $url = $site . $funnyurl And I get a successful combination leading directly to the file, this works so far in all my script, but I tried doing this entire script on one page, I am still fairly new to php, so my [b]main[/b] weakpoint is doing same page scripts.  If I have 5 scripts doing the same thing, or a form, I can never get it to work on same page, I haven't gotten there yet, but even now I am having trouble, I don't get it, any advice, I tried passing it normally, but variables don't pass like that, then I tried the hidden form field, the same with connections, I thought if you connected to a db, it stayed open in between scripts, but I had to reopen the connection on the other page as well.  IS there a reason the variable isn't getting read, or do I have to use a whole nothing db call for it to have access to the variable information, I thought variable information was passed through the form field.  Or is the other page not accessing the db for the information, if that is true, can't I just put my db connection, database seclecting, information retrieval, and extract function in a seperate page, and include them in all of them so all my scripts have the same access, or is this another issue?
  13. I just realized something, I was building my script, and trying to access a database variable on another page and I just realized something. What I was under the impression was, when you have a form, for instance, and you click submit, all php variables are carried over to that page.  I also thought, like if you had a master page with like 10 includes, all with functions and variables, Then you have a form, that submits to another page, I thought that other page would have access to all of that, but it turns out that the form doesn't and NOW I understand why the need for hidden form fields.  I was creating a admin page, and no matter what I couldn't get it to work on the same page, so I changed it over to it's own page, but it wasn't reading my variables, I had to use a hidden form field, why is it set up like this, I never noticed until recently. Also I had a security question If someone has a form, and it's going to something.php to get processed And on something.php it says if (isset($submitorsomeothervariable)) { // code to validate input // Code to update a database, and possibly provide password informaiton if the information was registered right // whatever } can't someone from even another website, like my website www.freelancebusinessman.com Can't I create a page on my site, www.freelancebusinessman.com/test.php or htm and then create a quick form and have it going to that website like www.website.com/processors/something.php as my action, if my form has the same submit name as the other processor. Won't my form hijack the processor and start running script off of it, I don't see any safety precautions that could prevent my script from hijacking that script, because the only thing in the script is if(isset($variable)  So if the variable is set the script runs, period, is this the case.
  14. Did anyone notice anything wrong with that?
  15. [code]<!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>Approval</title> </head> <body> <h3>Welcome Bobby</h3> <p>These are recently pending database entries, please accept/decline.  Please note declined entries are automatically permanently deleted from the database. These are all updated together, upon submit.  The ones that are approved are set to approved status, the ones that are declined, are immediately deleted from the database, and the file is removed from it's location on the server.  If you check some of the choice, and leave some of the choice alone, they will still be here later, for instance if there are 3 items listed.  If you approve 1, decline 1, and leave the other alone for now, the approved one is updated, the declined one is deleted, and the one left alone, is not touched, and left there, for you to update later.</p> <?php  // Connects to database $connect = mysql_connect("localhost", "#####", "####"); $select = mysql_select_db("funnyemailforwards"); $errorhandler = ""; $management = true; if (!$connect || !$select) { $errorhandler = "The database could not connect, or was not selected<br />"; $management = false; } ?> <?php if (isset($_POST['update'])) {       foreach ($_POST['approval'] as $key => $value) {     if ($value) {         mysql_query('DELETE FROM fileinfo WHERE id='.$key); unlink($funnyurl); // url is set to exactly like this // http://www.funnyemailforwards.com/apex/uploads/filename.ext // Follows a path exactly to the file.     } else {         mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key);     } }// closes foreach }// closes isset control structure ?> <?php // script to display information $result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC"); echo "<form name=\"dataupdating\" action=\"approval.php\" method=\"post\">"; while ($row = mysql_fetch_assoc($result)) { extract($row); $date = date("m/d/y"); $site = "http://www.funnyemailforwards.com/apex/"; $funnyurl = $site . $funnyurl; echo "<ul>"; echo "<li><a href=" . '"' . $funnyurl . '"' . 'target="_blank">' . $nameoffunny . "</a></li>"; echo "<li>" . $date . "</li>"; echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"1\">Approve</li>"; echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"0\">Decline</li>"; echo "</ul>";  $management = true; } if ($management === true) { echo "<input name=\"update\" type=\"submit\" value=\"Update Database\">"; echo "</form>"; } if ($errorhandler != "") { echo "$errorhandler"; $management = false; } ?> </body> </html>[/code] That is what I have but it's giving me troubles, it's working out properly when I use it, but 2 things are messing up, when I update, it updates the db properly for both, but ont he one that deletes it, it leaves the file, it tells me no file name, the file is in 2 folders, it is in this directory http://www.funnyemailforwards.com/apex/uploads/filehere The area for where I am using this script that does the updating here is in http://www.funnyemailforwards.com/administration/approval.php I need to figure out how to get it to access the file, I am currently trying to tell it the file location is http://www.funnyemailforwards.com/apex/uploads/file.ext That is what I am pointing it to, but it's not deleting it, it tells me the file does not exist.  Also when there are no entries in the database, a lot of things act up, for one it tells me my foreach statement [code]foreach ($_POST['approval'] as $key => $value) {[/code] It's telling me this, when there are none listed [quote]Warning: Invalid argument supplied for foreach() in /home/all/funnyemailforwards/public_html/administration/approval.php on line 23[/quote] Can anyone help me figure this out real quick?
  16. Ok I will put these into m ind, and check on the things you listed, thank you so much for the help, I really appreciate it.  Not only did I finish my script, or am finishing it, but I also gained extra knowledge, and a few new techniques, plus a script I can duplicate the form of for later work, thank you for your help, I will ask here more if I get stuck on it, but I can wait for answers, whenever you are on and have time, I think I understand this enough, I should be able to handle the rest, all the questions I had were answered, thanks for the help.
  17. [quote]foreach ($_POST['approval'] as $key => $value) {     if ($value) {         mysql_query('DELETE FROM fileinfo WHERE id='.$key); unlink($funnyurl); // url is set to exactly like this // http://www.funnyemailforwards.com/apex/uploads/filename.ext // Follows a path exactly to the file.     } else {         mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key); unlink($funnyurl); // url is set to exactly like this // http://www.funnyemailforwards.com/apex/uploads/filename.ext // Follows a path exactly to the file.     } }[/quote] That is what I have, is this going to work, because I was wondering, it seems to me if the value exists it will update the delete, if it's not it will update I need it to do both, or will this update both sections OH it's on foreach ok, now I get it. I want to ask here before using this, or I could mess up my database.  Does this work perfectly, is it true. What I am wondering is this going to work here is my entire script now, with your advice put in there. [code]<!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>Approval</title> </head> <body> <h3>Welcome Bobby</h3> <p>These are recently pending database entries, please accept/decline.  Please note declined entries are automatically permanently deleted from the database. These are all updated together, upon submit.  The ones that are approved are set to approved status, the ones that are declined, are immediately deleted from the database, and the file is removed from it's location on the server.  If you check some of the choice, and leave some of the choice alone, they will still be here later, for instance if there are 3 items listed.  If you approve 1, decline 1, and leave the other alone for now, the approved one is updated, the declined one is deleted, and the one left alone, is not touched, and left there, for you to update later.</p> <?php  // Connects to database $connect = mysql_connect("localhost", "######", "######"); $select = mysql_select_db("funnyemailforwards"); $errorhandler = ""; $management = true; if (!$connect || !$select) { $errorhandler = "The database could not connect, or was not selected<br />"; $management = false; } ?> <?php // script to display information $result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC"); echo "<form name=\"dataupdating\" action=\"approval.php\" method=\"post\">"; while ($row = mysql_fetch_assoc($result)) { extract($row); $date = date("m/d/y"); $site = "http://www.funnyemailforwards.com/apex/"; $funnyurl = $site . $funnyurl; echo "<ul>"; echo "<li><a href=" . '"' . $funnyurl . '"' . 'target="_blank">' . $nameoffunny . "</a></li>"; echo "<li>" . $date . "</li>"; echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"1\">Approve</li>"; echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"0\">Decline</li>"; echo "</ul>";  } echo "<input name=\"update\" type=\"submit\" value=\"Update Database\">"; echo "</form>"; foreach ($_POST['approval'] as $key => $value) {     if ($value) {         mysql_query('DELETE FROM fileinfo WHERE id='.$key); unlink($funnyurl); // url is set to exactly like this // http://www.funnyemailforwards.com/apex/uploads/filename.ext // Follows a path exactly to the file.     } else {         mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key);     } } if ($errorhandler != "") { echo "$errorhandler"; $management = false; } ?> <?php if (isset($_POST['update'])) { } ?> </body> </html>[/code]
  18. [code]<?php // script to display information $result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC"); echo "<form name=\"dataupdating\" action=\"approval.php\" method=\"post\">"; while ($row = mysql_fetch_assoc($result)) { extract($row); $date = date("m/d/y"); $site = "http://www.funnyemailforwards.com/apex/"; $funnyurl = $site . $funnyurl; echo "<ul>"; echo "<li><a href=" . '"' . $funnyurl . '"' . 'target="_blank">' . $nameoffunny . "</a></li>"; echo "<li>" . $date . "</li>"; echo "<li><input type=\"radio\" name=\"{$id[]}\" value=\"1\">Approve</li>"; echo "<li><input type=\"radio\" name=\"{$id[]}\" value=\"0\">Decline</li>"; echo "</ul>";  } echo "<input name=\"update\" type=\"submit\" value=\"Update Database\">"; echo "</form>";[/code] So that should be how I set up my form elements right? Or am I not understanding properly. And just for information purposes, I am not like other people, I try to avoid the personality where I refuse other people's advice, if I have been programming a specific way for 4 years, and all of a sudden someone comes by and shows me something, that is either harder, or I feel is useless, I am going to try it there way and see how I personall feel about it. [quote]Well, in the HTML you typed up there, you have PHP generating INPUT element names like "approve_123" which means you'll have to find every instance of array element (approve_*) within $_POST[] ($_POST['approve_*']).  It would just be easier to use a single array for the radio button form elements[/quote] I see what you mean about this possibly being difficult, I think I will try your idea, and see how it turns out, as I presented above, to get started. [quote]Where the "8" in that example would be the id of the entry in the database.  All of the radio button values that get set will reside in the variable $_POST['approval'].  So when you loop through the $_POST'ed variable, all you'd need is this:[/quote] So the I don't understand this fully, but I think you are telling me enough for what I created earlier, was that script up there what you meant. [quote]Did you notice the print_r of the array a few posts back?  See how the approval[n] array is set up?  You probably know that you can use form element names of the form "element_name[]" to return data from multiple elements of the same name into an array, right?  So that's all we're doing here, except we're also putting the id of the item as a key in the array (and the 0/1 will be the value).[/quote] But I understood none of the output like X, or the one below it, is that just to display what is selected and what is not?
  19. I just created my own thing, because I didn't fully understand what you mean.  Because with what i have I call the data, what do I do with it then, or more of, what did you mean by creating an array, I know about arrays, but I am a little confused ont his part.
  20. Just manually copy and paste them over, it would be the easiest way I think.  Or I guess youcould copy the file with php functions, and then place them in another folder, somewhere else just like you would do when someone uploads them, then unlink the file that you had.
  21. something like [code] while (decline_$row['id']) { // delete from, remove file } while (approve_$row['id]) { // Changes proper character to update database } [/code] The one thing I don't understand, is how would I format the query for decline would it be [code] if (isset($_POST['update])) { DELETE * FROM fileinfo WHERE decline_$row['id']; and then my file delete like unlink($fileurl);  // my file url is the full url http://www.funnyemailforwards.com/apex/uploads/filename.ext and then to update I could have UPDATE approval FROM fileinfo WHERE accept_$row['id] VALUES (1); } Is this somethign along the lines of how it would go.[/code]
  22. [code]<h3>Welcome Bobby</h3> <p>These are recently pending database entries, please accept/decline.  Please note declined entries are automatically permanently deleted from the database.</p> <?php $connect = mysql_connect("#####", "#####", "#######"); $select = mysql_select_db("funnyemailforwards"); $errorhandler = ""; $management = true; if (!$connect || !$select) { $errorhandler = "The database could not connect, or was not selected<br />"; $management = false; } $result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC"); echo "<form name=\"dataupdating\" action=\"approval.php\" method=\"post\">"; while ($row = mysql_fetch_assoc($result)) { extract($row); $date = date("m/d/y"); $site = "http://www.funnyemailforwards.com/apex/"; $funnyurl = $site . $funnyurl; echo "<ul>"; echo "<li><a href=" . '"' . $funnyurl . '"' . 'target="_blank">' . $nameoffunny . "</a></li>"; echo "<li>" . $date . "</li>"; echo "<li><input type=\"radio\" name=\"approve_{$row['id']}\" value=\"1\">Approve</li>"; echo "<li><input type=\"radio\" name=\"approve_{$row['id']}\" value=\"0\">Decline</li>"; echo "</ul>";  } echo "<input name=\"update\" type=\"submit\" value=\"Update Database\">"; echo "</form>"; if ($errorhandler != "") { echo "$errorhandler"; $management = false; } ?>[/code] Based on your advice and one other persons I wrote up this, it properly displays ALL of the information like it should.  What I am wondering now, is this what you meant, something like [code] <?php if (isset($update)) { //1 query to change that character //1 query to deleted what needs to be deleted and unlink the proper files. //Right ?> [/code]
×
×
  • 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.