Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. Humour me here and try the full path, but separate by colons, e.g. [code]HD:System Folder:Web Server:Users:UploadedFiles[/code] Where I've put HD, is the disk or volume name. Regards Huggie
  2. [quote author=taith link=topic=119231.msg488113#msg488113 date=1166533044] lol... but ajax is the greatest thing since sliced bread ;-) and not that hard to set up... lol [/quote] Which is where the problem comes in, overuse and not necessarily fit for purpose.  I remember the launch of Macromedia Flash :) Huggie
  3. Fair enough, but the overhead of adding AJAX into the equation when (s)he's spawning a new window for the preview anyway, It hardly seems worth it to me. Huggie
  4. Your welcome.  The [url=http://uk.php.net/manual/en/function.mail.php]mail()[/url] function on Windows acts very differently to that on *nix flavour boxes. I got the information that I needed from the [url=http://uk.php.net/manual/en/ref.mail.php]Mail reference page[/url] in the [url=http://uk.php.net/manual/en/index.php]PHP Manual[/url] though. Don't forget to use the new 'Solved' button on this topic. Regards Huggie
  5. Why not put them into an array then?  The array is keyed on number by default. [code]<?php // Prepare SQL $query = "SELECT groupName from messageGroups"; // Execute query $result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error()); // Put each row into an array, keyed on number (starting from 1, not 0) $key = 1 while ($row = mysql_fetch_assoc($result)){   $groups[$key] = $row['groupName'];   $key++; } ?>[/code] This also gives you the added advantage of being able to find out how many groups there are by using the count() function [code]<?php $number_of_groups = count($groups); ?>[/code] Also, doing something to each of the groups in turn is as simple as a foreach loop [code]<?php foreach ($groups as $key => $name){   // Change to first letter of the group to upper case and the rest to lower   $groups[$key] = ucfirst(strtolower($name)) } ?>[/code] Regards Huggie
  6. [quote author=taith link=topic=119231.msg488096#msg488096 date=1166529269] You would either need to use a) javascript or b) ajax [/quote] Why?  If it's having two separate buttons, why not just submit it to itself with a condition?  Imagine this... I have a page that has two html buttons on it, one called Submit and the other called Preview [code]<?php if (isset($_POST['Preview'])){   /*   Capture all the post variables here and use them to create the preview page   at the same time, you echo the form again with the values of the form automatically   filled out using the $_POST variables just captured.   */ } else if (isset($_POST['Submit'])){   /*   This time the actual form has been submitted so lets process it.   */ } ?>[/code] Regards Huggie
  7. Change the email address and the server name, upload it to the server, and then try loading it in a browser.  This is as simple as it gets, so don't try changing anything else just yet, lets see if we can at least get it sending. [code]<?php // This MUST be set to your mailserver (replace 'localhost') ini_set('SMTP', 'localhost'); // Who's the mail to $to_email = "email@address.co.uk"; // Test Subject $subject = "Test Email"; // Test Body $body = "This is our test message.\n"; // DO NOT ALTER $headers = "Content-type: text/plain"; if (mail($to_email, $subject, $body, $headers)){   echo "Success\n"; } else {   echo "Failed\n"; } ?>[/code] Huggie
  8. OK, have you tried changing the SMTP setting? Huggie
  9. I'm afraid in that case it looks as though you'll need a fax server.  I'm not versed enough to be able to offer any advice though I'm afraid. I'd offer google's services again :) Huggie
  10. Why doesn't the [color=green]mail()[/color] function work?  Do you know? Regards Huggie
  11. In that case, I'd have thought that the following would be better.  It's certainly slightly shorter. [code=php:0]$pattern = "/@((msn|hotmail)\.com|hotmail\.co\.uk)/";[/code] Regards Huggie
  12. As far as I'm aware you'll need a fax server.  If you have one of those up and running I don't see any reason why you couldn't fashion something together If you don't have a fax server then your next best thing is an 'email to fax' service that some companies offer.  You can send an email to an address and the service forwards it on as a fax, this is simple as it's really easy to send emails from PHP. Google for "email to fax" or email2fax or something similar, I'm sure you'll get plenty of hits. Regards Huggie
  13. I have a form that looks like this: [size=8pt][b]form.htm[/b][/size] [code]  <form name="upload" method="POST" action="process.php" enctype="multipart/form-data">   <input type="file" name="imagefile[]"><br>   <input type="file" name="imagefile[]"><br>   <input type="file" name="imagefile[]"><br>   <input type="file" name="imagefile[]"><br>   <input type="file" name="imagefile[]"><br>   <input type="submit" name="submit" value="Upload"><br><br>   </form>[/code] And the php that processes it like this: [size=8pt][b]process.php[/b][/size] [code]<?php // If the form has been submitted then process it if(isset($_POST['submit'])){   // Perform this action for each of the uploaded files   foreach ($_FILES['imagefile']['error'] as $k => $error){       if ($_FILES['imagefile']['error'][$k] == 0){         // Make sure the file is a jpeg         if ($_FILES['imagefile']['type'][$k] == "image/jpeg" || $_FILES['imagefile']['type'][$k] == "image/pjpeg"){             // Copy the temporary file to the original file name             copy($_FILES['imagefile']['tmp_name'][$k], "images/".$_FILES['imagefile']['name'][$k]) or die ("Could not copy");             echo "{$_FILES['imagefile']['name'][$k]}... Uploaded OK<br>\n";             // You could put your database insertion code here.         }         else {             echo "Could Not Copy, Wrong Filetype ({$_FILES['imagefile']['type'][$k]})<br>";         }       }   } } ?> [/code] Regards Huggie
  14. You just need to print the newlines... [code]<? //my includes here $p = "email_log_".date("d_m_y").".txt"; header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header("Content-type: text/plain"); header("Content-Disposition: attachment; filename=\"$p\""); header("Content-Transfer-Encoding: binary"); $email_list = getRows("logID, email, log_timestamp, subject, body", "email_logs", "log_timestamp >= '2006-12-13'"); foreach ($email_list as $email_record){ echo "Log ID: ".$email_record['logID']."-----------------------------\n"; echo "Email Address: ".$email_record['email']."\n"; echo "Date: ".date("d-m-Y H:i:s",strtotime($email_record['log_timestamp']))."\n\n"; echo "Subject: ".$email_record['subject']."\n"; echo "Message: ".strip_tags($email_record['body'])."\n"; } ?>[/code] Incidentally, is the Content-Transfer-Encoding correct?  If it's just text, should it not be in ASCII? Regards Huggie
  15. If it's code you're using from somewhere else you don't always have much choice unless you're going to re-write it. So the first command ob_start() says don't output anything!  Everything you come across that's meant to be output, place it into the buffer instead. Then the ob_end_flush() says dump everything I have in my buffer to the screen. Regards Huggie
  16. You need to use a foreach loop really.  Never copy and paste the same code.  If the same code's being used more than once, then surely there's cause for a function there? You obviously have a form that contains five fields called img1, img2, img3, img4, and img5.  First thing you need to do is change the names of these.  You want to submit an array rather than individual names, so rename them something like images[] (make sure whatever you call the field, you have the square brackets after it e.g. [code] <input type="file" name="images[]"> <input type="file" name="images[]"> <input type="file" name="images[]"> <input type="file" name="images[]"> <input type="file" name="images[]"> [/code] I'll post some sample code a little later so you can see something similar that I have. Regards Huggie
  17. I'm afraid I didn't get a chance to look, but replace the code you posted earlier with this and see if it makes much of a difference.  It's buffering the output of that entire table, so it shouldn't print the start of that table until it has all of the results. [code] <?php   // Start buffering the output   ob_start(); ?> <table id="domeinnaamchecker" width="538" height="66" border="0" cellpadding="0" cellspacing="0">   <tr>     <td colspan="3"><img src="images/cdomeinnaamcheck.jpg" width="538" height="46" /></td>   </tr>   <tr>     <td width="14" height="100%" background="images/laatstenieuws_02.jpg">&nbsp;</td>     <td width="510" height="100%" nowrap="nowrap" bgcolor="FFFFFF"><table width="510" border="0" cellspacing="0" cellpadding="0">       <tr>         <td align="center" nowrap="nowrap">             <br />             <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain" id="domain">               <table width="510" border="0" cellspacing="0" cellpadding="0">                 <tr>                   <td align="center">www.                   <input class="text" name="domainname" type="text" size="36" /></td>                 </tr>                 <tr>                   <td height="25" align="center" valign="middle"><br />                     <table width="510" border="0" cellspacing="0" cellpadding="0">   <tr>     <td width="12%" height="20">&nbsp;</td>     <td width="22%" height="20"><input type="checkbox" name="nl"/> .nl</td>     <td width="22%" height="20"><input type="checkbox" name="be" /> .be</td>     <td width="22%" height="20"><input type="checkbox" name="de" /> .de </td>     <td width="22%" height="20"><input type="checkbox" name="eu" /> .eu</td>   </tr>   <tr>     <td width="12%" height="20">&nbsp;</td>     <td width="22%" height="20"><input type="checkbox" name="com" /> .com </td>     <td width="22%" height="20"><input type="checkbox" name="net" /> .net </td>     <td width="22%" height="20"><input type="checkbox" name="org" /> .org </td>     <td width="22%" height="20"><input type="checkbox" name="info" /> .info </td>   </tr>   <tr>     <td width="12%" height="20">&nbsp;</td>     <td width="22%" height="20"><input type="checkbox" name="biz" /> .biz </td>     <td width="22%" height="20"><input type="checkbox" name="nu" /> .nu </td>     <td width="22%" height="20"><input type="checkbox" name="name" /> .name </td>     <td width="22%" height="20"><input type="checkbox" name="ws" /> .ws </td>   </tr>   <tr>     <td width="12%" height="20">&nbsp;</td>     <td width="22%" height="20"><input type="checkbox" name="tv" /> .tv </td>     <td width="22%" height="20"><input type="checkbox" name="co.uk" /> .co.uk </td>     <td width="22%" height="20"><input type="checkbox" name="mobi" /> .mobi </td>     <td width="22%" height="20"><input type="checkbox" name="cc" /> .cc</td>   </tr>   <tr>     <td width="12%" height="20">&nbsp;</td>     <td width="22%" height="20"><input type="checkbox" name="ca" /> .ca </td>     <td width="22%" height="20"><input name="alle" type="checkbox" checked="checked" />       alles</td>     <td width="22%" height="20">&nbsp;</td>     <td width="22%" height="20">&nbsp;</td>   </tr> </table></td>                 </tr>                 <tr>                   <td align="center" valign="middle"><br/>                       <input class="text" type="submit" name="submitBtn" value="Controleer" /></td>                 </tr>               </table>             </form>             <hr />           <table width="272px"> <?php     function checkDomain($domain,$server,$findText){         // Open a socket connection to the whois server         $con = fsockopen($server, 43);         if (!$con) return false;                 // Send the requested doman name         fputs($con, $domain."\r\n");                 // Read and store the server response         $response = ' :';         while(!feof($con)) {             $response .= fgets($con,128);         }                 // Close the connection         fclose($con);                 // Check the response stream whether the domain is available         if (strpos($response, $findText)){             return true;         }         else {             return false;          }     }         function showDomainResult($domain,$server,$findText){       if (checkDomain($domain,$server,$findText)){           echo "<tr><td width=\"222\" align=\"left\">$domain</td><td width=\"50\" align=\"center\"><span class=\"dhvrij\">vrij</span></td></tr>";       }       else echo "<tr><td width=\"222\">$domain</td><td width=\"50\" align=\"center\"><span class=\"dhbezet\">bezet</span></td></tr>";     }     if (isset($_POST['submitBtn'])){         $domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';         $d_all      = (isset($_POST['alle'])) ? 'alle' : '';            $d_nl      = (isset($_POST['nl'])) ? 'nl' : '';            $d_be      = (isset($_POST['be'])) ? 'be' : '';          $d_de      = (isset($_POST['de'])) ? 'de' : '';            $d_eu      = (isset($_POST['eu'])) ? 'eu' : '';            $d_com      = (isset($_POST['com'])) ? 'com' : ''; $d_net      = (isset($_POST['net'])) ? 'net' : '';            $d_org      = (isset($_POST['org'])) ? 'org' : '';            $d_info      = (isset($_POST['info'])) ? 'info' : ''; $d_biz      = (isset($_POST['biz'])) ? 'biz' : '';            $d_nu      = (isset($_POST['nu'])) ? 'nu' : '';            $d_name      = (isset($_POST['name'])) ? 'name' : '';  $d_ws      = (isset($_POST['ws'])) ? 'ws' : '';            $d_tv      = (isset($_POST['tv'])) ? 'tv' : '';            $d_couk      = (isset($_POST['co.uk'])) ? 'co.uk' : '';  $d_mobi    = (isset($_POST['mobi'])) ? 'mobi' : '';            $d_cc    = (isset($_POST['cc'])) ? 'cc' : '';            $d_ca      = (isset($_POST['ca'])) ? 'ca' : '';                        // Check domains only if the base name is big enough         if (strlen($domainbase)>2){         if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".nl",'whois.domain-registry.nl','is free'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".be",'whois.dns.be','FREE'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".de",'whois.nic.de','free'); if (($d_eu != '') || ($d_all != '') ) showDomainResult($domainbase.".eu",'whois.eu','FREE'); if (($d_com != '') || ($d_all != '') ) showDomainResult($domainbase.".com",'whois.crsnic.net','No match for');             if (($d_net != '') || ($d_all != '') ) showDomainResult($domainbase.".net",'whois.crsnic.net','No match for');             if (($d_org != '') || ($d_all != '') ) showDomainResult($domainbase.".org",'whois.publicinterestregistry.net','NOT FOUND'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".info",'whois.afilias.net','not found'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".biz",'whois.nic.biz','not found'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".nu",'whois.nic.nu','not found'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".name",'whois.nic.name','no match'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".ws",'whois.ripe.net','No entries found'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".tv",'whois.nic.tv','no match'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".couk",'whois.nic.uk','no match'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".mobi",'whois.dotmobiregistry.net','is free'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".cc",'whois.domain-registry.nl','is free'); if (($d_nl != '') || ($d_all != '') ) showDomainResult($domainbase.".ca",'whois.cira.ca','is free'); // Flush the buffer as we've got all our results now. ob_end_flush(); ?>             </table>           <?php                    }     } ?>             <hr />        </td>       </tr>       <tr>         <td align="center"><span class="pa">Aan de resultaten van de domeinnaamcheck kunnen geen rechten worden ontleend.<br />           <br />         </span></td>       </tr>     </table> </td>     <td width="14" height="100%" background="images/laatstenieuws_04.jpg">&nbsp;</td>   </tr>   <tr>     <td colspan="3"><img src="images/laatstenieuws_05.jpg" width="538" height="18" alt="" /></td>   </tr> </table>[/code] Regards Huggie
  18. No, there's no need for that.  It's only the cookie variable that can't be used on the same page, you could use the $_POST or $_GET variable instead. Here's an example of what I mean... [code]<?php // Get the city from the drop down list or whatever you have $city = $_GET['city']; // Assign the value to a cookie setcookie('cookie_city', $_GET['city'], time()+3600); // This won't work echo $_COOKIE['cookie_city']; // doesn't get set until the next page load // But this will echo $_GET['city']; ?>[/code] So if you need to use the value of a cookie on the same page that you set it, just use the source, where the cookie came from. Regards Huggie
  19. I don't think so either.  Something like this for alternation... [code]<?php $pattern = "/(msn|hotmail)\.(com|co\.uk)/"; if (preg_match($pattern, $string)){   echo "Yes"; } ?>[/code] Although this will include msn.co.uk Regards Huggie
  20. You're getting this result because you're testing for truth by using negativity.  In this instance you'd want AND. [code]<?php if ($yes != "" && $yes != "no"){ //do something here } ?>[/code] Regards Huggie
  21. Yes that's correct. This was taken from the [url=http://uk.php.net/manual/en/function.setcookie.php]setcookie()[/url] page in the manual: [quote] Once the cookies have been set, they can be accessed on the next page load with the $_COOKIE or $HTTP_COOKIE_VARS arrays. [/quote] Regards Huggie
  22. You could split it based on the & sign. [code]<?php // printing out if (!isset($_COOKIE['cookie_city'])){   echo '<a href="/mcity.php">Please select a city[/url]'; } else {   $cookie_parts = explode("&", $_COOKIE['cookie_city']);   echo "Your cookie is set to {$cookie_parts[0]}!"; } ?>[/code] Regards Huggie
  23. Have a separate folder for each user, it could be just named the same as their unique user_id or something.  Call the page something like listfiles.php and have it in the users directory (one directory above the individual user directories) then when the user logs in (which I'm assuming they do, unless you're allowing anyone to randomly upload files to your server) use the userid in a session variable, or something similar to list the directory contents... Something like this: [size=8pt][b]listfiles.php[/b][/size] [code]<?php // Path to the files $path = '/root/users/' . $_SESSION['user_id']; // Open the directory $dh = opendir($path); while (($file = readdir($dh)) !== false){   if ($file != '.' && $file != '..'){       echo "$file<br>\n";   } } ?>[/code] This should list different files depending on which user is logged in. Huggie
  24. [quote author=heckenschutze link=topic=119165.msg487689#msg487689 date=1166478628] if the value of submit was "0" then [color=blue]if($_POST['submit'])[/color] would not return expected results. [/quote] This actually came up in this forum today on one of the posts. Huggie
  25. Shouldn't be too difficult... [code]<?php // connect to database include('connect.php'); // clear the table down $sql = "TRUNCATE TABLE table_name"; mysql_query($sql); // open the csv file $data = file('/path/to/your/file/goes_here.csv'); // create an insert statement for each row in the csv file foreach ($data as $row){   $cols = explode(",", $row); // put each piece of data seperated by a comma, into an array called $cols   $sql = "INSERT INTO table_name (column_1, column_2, column_3) VALUES ('$cols[0]', '$cols[1]', '$cols[2]')";   mysql_query($sql); } ?>[/code] This has no error checking on it, but it should work OK, Regards Huggie
×
×
  • 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.