Jump to content

websponge

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Everything posted by websponge

  1. ok, noted, will make sure I do this, but can anyone help please?
  2. I tried to edit it! sorry.. stupid IE9! well its supposed to display all the fields, but it doesnt. I select an app from the dropdown list, for example "payroll" and I want the query to execute so it displays all the fileds for that record. the php for listing all the fields looks like this: $query="select * from ofcom where appname='Payroll'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo "<div id='recordholder'>"; echo "<div id='database-heading'>". $row['appname'] . "</div>"."<div id='description'>" . $row['description'] . "</div>"; echo "<div id='opcatholder'><div id='opcatheader'>Operational Cataogories</div><div id='opcat'><span class='op'>OP CAT 1 - </span>".$row['opcat1'] ."</div><div id='opcat'> <span class='op'>OP CAT 2 - </span>".$row['opcat2'] ."</div><div id='opcat'><span class='op'>OP CAT 3 - </span>".$row['opcat3'] ."</div></div>"; /*echo "<div id='routingheader'>Routing Information</div>";*/ echo"<div id='info'>".$row['info']."</div>"; echo "<div id='opcatholder'><div id='opcatheader'>Routing</div>".$row['routing']."</div>"; echo "</div>"; echo "<br clear='all' />"; } as you can see, ive manually set it too Payroll so that it works.. I want the listbox to execute the query when I select the app.. really hard to explain and ive been on this all day thanks for replying
  3. well its supposed to display all the fields, but it doesnt. I select an app from the dropdown list, for example "payroll" and I want the query to execute so it displays all the fileds for that record. the php for listing all the fields looks like this: $query="select * from ofcom where appname='Payroll'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo "<div id='recordholder'>"; echo "<div id='database-heading'>". $row['appname'] . "</div>"."<div id='description'>" . $row['description'] . "</div>"; echo "<div id='opcatholder'><div id='opcatheader'>Operational Cataogories</div><div id='opcat'><span class='op'>OP CAT 1 - </span>".$row['opcat1'] ."</div><div id='opcat'> <span class='op'>OP CAT 2 - </span>".$row['opcat2'] ."</div><div id='opcat'><span class='op'>OP CAT 3 - </span>".$row['opcat3'] ."</div></div>"; /*echo "<div id='routingheader'>Routing Information</div>";*/ echo"<div id='info'>".$row['info']."</div>"; echo "<div id='opcatholder'><div id='opcatheader'>Routing</div>".$row['routing']."</div>"; echo "</div>"; echo "<br clear='all' />"; } as you can see, ive manually set it too Payroll so that it works.. I want the listbox to execute the query when I select the app.. really hard to explain and ive been on this all day thanks for replying
  4. Hi, Im starting to write a simple (so I thought! ) project at work, I have no problems with the HTML, CSS or even the php mysql setup, but I am struggling with a simple piece of code! I have a list box, that populates from a table column using the following code: <?php function select(){ $query="SELECT appname FROM kpe_apps"; $result = mysql_query($query); echo '<select name="item" onchange="this.form.submit()">'; while($nt=mysql_fetch_array($result)){ echo '<option value="' . $nt['id'] . '">' . $nt['appname'] . '</option>'; } echo '</select>'; } ?> I then called the function on the page I needed. which works fine, now all I need is whatever is selected in the listbox other columns in the same table relating to the selected item are seen. I just cant seem to do it, loads of people are using jquery and other code, surely this can be done in php? any help would really be appreciated.. Many Thanks MOD EDIT: code tags fixed, linefeeds and indenting added.
  5. Awesome! thankyou very much.. I get it!
  6. right! ive never seen the "implode" command, this makes sense, thankyou, how would I get the emails into an array? I dont want to type them all out..?
  7. Im just a bit stuck on what the code should be, I can select all emails from the member table, but dont know how to send an email to all of them? Thanks
  8. Gentle bump :'(
  9. anyone please?
  10. thanks, I can get all the email address to display, like the link you gave, thats not the problem, I need to do what you said, and send one email to all recipients with BCC but I dont know how.. thanks again
  11. Hi, Im getting better at this php lark! ok so now I have a signup website page, all details get added to the database including an email address, all works fine. now I would like a page, with a simple text box, that when you hit submit, it send the contents of the text box to all email address` in the members table, a really really simple newsletter so to speak. Its purely for my learning curve and Ill set up recapacha on it anyway. but Im getting a bit lost in the code, could someone guide me please? I can grab the contents of the text box like this: $letter = $_POST['letter]; but how do I send to all recipients? $recipient = ("SELECT email FROM members"); thanks
  12. The best way to do this is to use the existing phpbb template system and design the rest of your website pages to use it, you can include the overall _header and footer files in your web pages, there are many articles on this on the phpbb website.
  13. It now works with the above code, many thanks all, especially zanus
  14. if($_POST['action'] == "demotivate") { upload("demotivate"); } else if($_POST['action'] == "nsfw") { upload("nsfw"); } else if($_POST['action'] == "fail") { upload("fail"); } ?>
  15. You define the directory name when you call the function.. For instance nsfw("someDirectory"); I put that in the function call, it doesnt work can you help?
  16. sorry guys im lost, thats too much for me to understand at this moment! thanks anyway
  17. oh wait, where am I defining the directory name? and I still have to repeat all the code for each funtion dont I?
  18. Brilliant! I totally forgot that you can assign variable to the same function, im learning all the way on this site, you guys are awesome. Thankyou, Im giving it a whirl now.
  19. Hi, Ive had a website for some time that allows people to upload pictures to certain directories, and each directory had its own upload script, I decided as Im slowley getting better at php to combine it all into 1 file and include it, all works great, but now I notice its a lot of repeated code as the only thing that changes for each function is the directory name, here is the script as it is: <?php // James Davies, Revised 2010 // Create the main NSFW upload function function demotivate() { //configure site specific variables $website = 'http://www.thenudedeer.com'; //what is the folder name $phpbbdir = '/demotivate/'; // Create an array containing all valid upload file types for this script $allowed_types = array( "image/gif" => "gif", "image/pjpeg" => "jpg", "image/jpg" => "jpg", "image/jpeg" => "jpg", "image/png" => "png", "image/x-png" => "png", // Add more types here if you like ); // Check to see if the file type is in the allowed types array if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) { die("Invalid file type."); } // Set the maximum uploadable file size => 512000 = 500kb $maxfilesize = 512000; // Is the file larger than it is allowed to be? if($_FILES['userfile']['size'] > $maxfilesize) { die("File too large"); } // Where will the file be uploaded to? $uploaddir = $_SERVER['DOCUMENT_ROOT'] . $phpbbdir; // What is the files temporary name? $file = $_FILES['userfile']['tmp_name']; // What is the files actual name? $filename = $_FILES['userfile']['name']; // Does this file already exist on the server? if(file_exists($uploaddir . $filename)) { //die("A file with that name already exists on this server."); die("File already existed, [img=http://" . $website . $phpbbdir . $filename ."]"); } else { // This file does not already exist, so copy it. copy($file, $uploaddir.$filename) or die("Could not copy file."); } // All done! :-) echo "<br />"; echo "<font color=red><b>"; echo "Upload successful"; echo "<br />"; echo "Copy and Paste the following Code"; echo "</font><br/>"; echo "<font color='green'><b>"; echo "<br />"; echo "[img]http://" . $website . $phpbbdir . $filename; echo "[/img]"; echo "<br/>"; echo "<br/>"; echo '<img class="img" src="' .$phpbbdir .$filename.'">'; echo "<br />"; echo "<br />"; echo "</font>"; echo "<br /><br />"; } function nsfw() { //configure site specific variables $website = 'http://www.thenudedeer.com'; //what is the folder name $phpbbdir = '/nsfw/'; // Create an array containing all valid upload file types for this script $allowed_types = array( "image/gif" => "gif", "image/pjpeg" => "jpg", "image/jpg" => "jpg", "image/jpeg" => "jpg", "image/png" => "png", "image/x-png" => "png", // Add more types here if you like ); // Check to see if the file type is in the allowed types array if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) { die("Invalid file type."); } // Set the maximum uploadable file size => 512000 = 500kb $maxfilesize = 512000; // Is the file larger than it is allowed to be? if($_FILES['userfile']['size'] > $maxfilesize) { die("File too large"); } // Where will the file be uploaded to? $uploaddir = $_SERVER['DOCUMENT_ROOT'] . $phpbbdir; // What is the files temporary name? $file = $_FILES['userfile']['tmp_name']; // What is the files actual name? $filename = $_FILES['userfile']['name']; // Does this file already exist on the server? if(file_exists($uploaddir . $filename)) { //die("A file with that name already exists on this server."); die("File already existed, [img=http://" . $website . $phpbbdir . $filename ."]"); } else { // This file does not already exist, so copy it. copy($file, $uploaddir.$filename) or die("Could not copy file."); } // All done! :-) echo "<br />"; echo "<font color=red><b>"; echo "Upload successful"; echo "<br />"; echo "Copy and Paste the following Code"; echo "</font><br/>"; echo "<font color='green'><b>"; echo "<br />"; echo "[img]http://" . $website . $phpbbdir . $filename; echo "[/img]"; echo "<br/>"; echo "<br/>"; echo '<img class="img" src="' .$phpbbdir .$filename.'">'; echo "<br />"; echo "<br />"; echo "</font>"; echo "<br /><br />"; } function fail() { //configure site specific variables $website = 'http://www.thenudedeer.com'; //what is the folder name $phpbbdir = '/fail/'; // Create an array containing all valid upload file types for this script $allowed_types = array( "image/gif" => "gif", "image/pjpeg" => "jpg", "image/jpg" => "jpg", "image/jpeg" => "jpg", "image/png" => "png", "image/x-png" => "png", // Add more types here if you like ); // Check to see if the file type is in the allowed types array if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) { die("Invalid file type."); } // Set the maximum uploadable file size => 512000 = 500kb $maxfilesize = 512000; // Is the file larger than it is allowed to be? if($_FILES['userfile']['size'] > $maxfilesize) { die("File too large"); } // Where will the file be uploaded to? $uploaddir = $_SERVER['DOCUMENT_ROOT'] . $phpbbdir; // What is the files temporary name? $file = $_FILES['userfile']['tmp_name']; // What is the files actual name? $filename = $_FILES['userfile']['name']; // Does this file already exist on the server? if(file_exists($uploaddir . $filename)) { //die("A file with that name already exists on this server."); die("File already existed, [img=http://" . $website . $phpbbdir . $filename ."]"); } else { // This file does not already exist, so copy it. copy($file, $uploaddir.$filename) or die("Could not copy file."); } // All done! :-) echo "<br />"; echo "<font color=red><b>"; echo "Upload successful"; echo "<br />"; echo "Copy and Paste the following Code"; echo "</font><br/>"; echo "<font color='green'><b>"; echo "<br />"; echo "[img]http://" . $website . $phpbbdir . $filename; echo "[/img]"; echo "<br/>"; echo "<br/>"; echo '<img class="img" src="' .$phpbbdir .$filename.'">'; echo "<br />"; echo "<br />"; echo "</font>"; echo "<br /><br />"; } ?> there must be a way to stop repeating all the same code for each function? many thanks
  20. that did it! thanking you, didnt realise the session had to be started before everything! thanks both!
  21. Tried that, it doesnt display the username, perhaps this is too much for me to learn
  22. Thats my understanding too, so why bother declaring it in the register.php page if it wont get passed to the next page?
  23. Thats what I dont understand, I never ask to use that variable again, I have to declare a new one in index2.php with this line: $username= $_SESSION['username']; I dont know why I have to do it twice if you like? sorry its a dull question.. once I get the post details, can I register it on register.php and not do it again on index2.php
  24. Im pretty new to PHP, but have managed to create a login system for a small site, my question relates to why Im entering a certain piece of code, I understand the code apart from the getting the information from a form and assigning it to a variable, I have a username form with one submit button, (username) which goes to a script called register.php I have this in my php: <?php error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); $username=$_POST['username']; session_register("username"); header("location:index2.php"); ?> then in my index2.php page i have this: <?php error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); session_start(); $username= $_SESSION['username']; ?> <!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=utf-8" /> <title>My Page</title> </head> <body> <p> Hi <?php echo $username; ?> </p> </body> </html> Ive simplified what ive done here,why am I declaring a variabel to get the form contents? cant I just get the contents? and then register? I dont need a variable.. If I remove the line, it doesnt work obviously.. thanks
×
×
  • 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.