Jump to content

fastsol

Moderators
  • Posts

    827
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by fastsol

  1. Be careful this site is using a javascript virus that my AVG picked up on.
  2. Give the table a id and then target all the css at that id for the cells and rows.
  3. It should seriously only take maybe an extra 5th of a second for the server to run the queries, I wouldn't worry about it.
  4. Well it's fairly simple to put this in a function, but you will need to feed the function a parameter from the db of the file extension. function functioname($fe) { if($fe == 'unknown'){$doc_extension = 'unknown'; $file_type = 'Unknown';} elseif(($fe=='docx')||($fe=='doc')||($fe=='docm')||($fe=='dotx')||($fe=='dotm')||($fe=='pages')||($fe=='wps')){$doc_extension='docx';$file_type='Word Document';} elseif(($fe=='pdf')||($fe=='pdp')){$doc_extension='pdf';$file_type='PDF';} elseif(($fe=='xlsx')||($fe=='xlsm')||($fe=='xlsb')||($fe=='xltx')||($fe=='xltm')||($fe=='xls')||($fe=='xlt')||($fe=='xls')||($fe=='csv')){$doc_extension='xlsx';$file_type='Excel Document';} elseif(($fe=='zip')||($fe=='zipx')||($fe=='tar')||($fe=='gz')||($fe=='z')||($fe=='cab')||($fe=='rar')||($fe=='bz2')||($fe=='lzh')||($fe=='7z')||($fe=='img')||($fe=='iso')){$doc_extension='zip';$file_type='Zip Folder';} elseif(($fe=='jpg')||($fe=='jpeg')||($fe=='jpe')){$doc_extension='jpg';$file_type='JPEG Image';} elseif(($fe=='png')||($fe=='pns')){$doc_extension='jpg';$file_type='PNG Image';} elseif(($fe=='gif')){$doc_extension='jpg';$file_type='GIF Image';} elseif(($fe=='tiff')||($fe=='tif')){$doc_extension='jpg';$file_type='TIFF/TIF Image';} elseif(($fe=='psb')||($fe=='bmp')||($fe=='rle')||($fe=='dib')||($fe=='eps')||($fe=='iff')||($fe=='tdi')||($fe=='jpf')||($fe=='jpx')||($fe=='jp2')||($fe=='j2c')||($fe=='j2k')||($fe=='jpc')||($fe=='jps')||($fe=='mpo')||($fe=='pcx')||($fe=='raw')||($fe=='pxr')||($fe=='pbm')||($fe=='ppm')||($fe=='pnm')||($fe=='pfm')||($fe=='pam')){$doc_extension='jpg';$file_type='Image File';} elseif(($fe=='mp3')){$doc_extension='mp3';$file_type='MP3';} else { $doc_extension = 'unknown'; $file_type = 'Unknown'; } $types = array('fe' => $fe, 'type' => $file_type); return $types; } Then you would call and use it like this $type = functionname($db['row']); // $db['row'] would be whatever you are using for info from the db. print_r($type); // this is just to show you how it comes back from the function. You would simply do checks against the specific array item.
  5. Browsers will still render the page with the added tags but it's not correct in any way. It's probably Dreamweaver seeing the double tags.
  6. $today = date("d/m/Y"); mysql_query("UPDATE `table` SET `column` = 0 WHERE `expire_date` < $today"); I did a little assuming on the $today and expire_date, this may not work correctly depending on the format you have the date stored in the db. If it's in a DATE format it might work right that way, otherwise I suggest reading up on the mysql date formats and queries for such things.
  7. If this is the entire content of whit_head.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <table><tr><td> This is my header </td></tr></table> </body> </html> You need to get rid of everything besides what inside the body tags. You're basically putting another <head> and <html> and body tags in side the file rather than just the html that needs to be included. From what it looks like, you results would be like this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <p>more text goes here</p> <p> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <table><tr><td> This is my header </td></tr></table> </body> </html> </p> <?php echo('test value');?> </body> </html>
  8. No idea, you didn't show us how you were getting the value of ['term'] to the page in the first place. So $_POST could be correct if you're using a form to send that data and the form method is set to "post".
  9. Ok well then you're not getting any results from the query or the query is failing. You need to start diagnosing that part first.
  10. Do you have error reporting turned on? What do you get if you do a print_r($data); Are you sure the query isn't failing?
  11. This is a working example, there are a couple ways you could tweak this depending on your needs. http://jsfiddle.net/fastsol/6nXxe/1/ I wanted to do the check on keyup but then you couldn't even change the last number cause it would obviously be less than the 1.55, so went with focusout instead.
  12. You had this if (filter_var($fr_email, FILTER_VALIDATE_EMAIL) === FALSE) As this before if (filter_var($email, FILTER_VALIDATEEMAIL) === FALSE) Can't remember if there was anymore, but those for sure.
  13. I fixed them in the code I posted.
  14. And you also had some variable misspellings and function misspellings too, fixed those.
  15. Here is a reworked version of what you just posted. I tested and it works. <!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" lang="en" > <head> <title> Firewall Request Form</title> </head> <body> <h2>Firewall Request Form</h2> <?php //date for time stamp on page $date = date("l F j, o g:i:s a"); //variable error array $error = array(); //error data in the variable for each element $iperror = "IP Address: Please fill out the source/destiantion IP address."; $porterror = "Port: Please fill out the source/destiantion port."; $protocolerror = "Protocol: Please fill out the protocol required(i.e. TCP...UDP)."; $apperror = "Application: Please fill out the source/destiantion application."; $reasonerror = "Description/Reason: Please fill out the reason/description box"; $emailerror = "Email: Please fill out the username/email."; if (isset($_POST['submit'])) { //pass POST to variables $fr_sd_ip = $_POST['fr_sd_ip']; $fr_sd_port = $_POST['fr_sd_port']; $fr_protocol = $_POST['fr_protocol']; $fr_sd_app = $_POST['fr_sd_app']; $fr_reason = $_POST['fr_reason']; $fr_email = $_POST['fr_email']; if (!filter_var($fr_sd_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){ $error[] = $iperror; } //Ports //http://stackoverflow.com/questions/6726450/check-for-valid-hostport-combination if (empty($fr_sd_port)){ $error[] = $porterror; } //protocol if (empty($fr_protocol)){ $error[] = $protocolerror; } //application if (empty($fr_sd_app)){ $error[] = $apperror; } //description if (empty($fr_reason)){ $error[] = $reasonerror; } if (filter_var($fr_email, FILTER_VALIDATE_EMAIL) === FALSE){ $error[] = $emailerror; //'Email: Please submit a valid email.'; } if (!empty($error)){ foreach($error as $errorsoutput){ //html formatting plus the error message echo $errorsoutput.'<br>'; } } else{ $success = 'Your firewall request form has been submitted.'; echo $success; } } ?> <form action="" method="POST"> <!-- This form is setup to allow the user to request changes to the firewall with requirements needed outlined in the form below. Fields needed are: Description, Source/Dest. port,Source/Dest. ip, Source/Dest. Application, Protocol (i.e. TCP, UDP, etc.), Username/Email --> <table width="525px"> <tr> <td valign="top" size="35%"> <label for="fr_sd_ip">Source/Dest. IP Address: *</label> </td> <td valign="top"> <input type="text" name="fr_sd_ip" maxlength="30" size="20" value="<?php echo (isset($_POST['fr_sd_ip'])) ? htmlentities($_POST["fr_sd_ip"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"> <?php /*if (isset($_POST["fr_sd_ip"]) && $errorsoutput == $iperror){echo $errorsoutput;} */?></span> </td> </tr> <tr> <td valign="top"> <label for="fr_sd_port">Source/Dest. Port: *</label> </td> <td valign="top"> <input type="text" name="fr_sd_port" maxlength="30" size="20" value="<?php echo (isset($_POST['fr_sd_port'])) ? htmlentities($_POST["fr_sd_port"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"> <?php /*if (isset($_POST["fr_sd_port"]) && $errorsoutput == $porterror){echo $errorsoutput;}*/ ?></span> </td> </tr> <tr> <td valign="top"> <label for="fr_protocol">Protocol: *</label> </td> <td valign="top"> <input type="text" name="fr_protocol" maxlength="30" size="20" value="<?php echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"> <?php /*if (isset($_POST["fr_protocol"]) && $errorsoutput == $protocolerror){echo $errorsoutput;}*/ ?></span> </td> </tr> <tr> <td valign="top"> <label for="fr_sd_app">Application: *</label> </td> <td valign="top"> <input type="text" name="fr_sd_app" maxlength="30" size="20" value="<?php echo (isset($_POST['fr_sd_app'])) ? htmlentities($_POST["fr_sd_app"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"> <?php /*if (isset($_POST["fr_sd_app"]) && $errorsoutput == $apperror){echo $errorsoutput;}*/ ?></span> </td> </tr> <tr> <td valign="top"> <label for="fr_reason">Description/Reason: *</label> </td> <td valign="top"> <textarea name="fr_reason" maxlength="500" col="20" rows="8" placeholder="Describe the scenario..."> <?php echo (isset($_POST['fr_reason'])) ? htmlentities($_POST["fr_reason"]) : ''; ?></textarea> </td> <td size="45%"> <span class="error" style="color:#FF0000"> <?php /*if (isset($_POST["fr_reason"]) && $errorsoutput == $reasonerror){echo $errorsoutput;}*/ ?></span> </td> </tr> <tr> <td valign="top"> <label for="fr_email">Username/Email: *</label> </td> <td valign="top"> <input type="text" name="fr_email" maxlength="30" size="20" value="<?php echo (isset($_POST['fr_email'])) ? htmlentities($_POST["fr_email"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"> <?php /*if (isset($_POST["fr_email"]) && $errorsoutput == $emailerror){echo $errorsoutput;}*/ ?></span> </td> </tr> </table> <input type="submit" value="Email Firewall Request" name="submit"/> <br /><br /> <?php echo "\nToday is: $date"; ?> <br /> <tr> <td valign="top"> <?php /*echo $fieldsrequired; if (isset($errorsoutput)){ echo $errorsoutput;}*/ ?> </td> </tr> </form> <br/> </body> </html>
  16. Just so you know, you can't see any php code when you view the source of a page in the browser. All the php is server side and doesn't show client side.
  17. I believe that responsive design will be more and more important as mobile only gets bigger. I have used responsive on a couple of my sites and really like how it makes it easier to navigate and read content on those sites for my phone, I can only imagine that customers appreciate that just as much. I don't really understand the use of a mobile domain, it's just seems like making 2 sites for the same purpose when responsive would achieve most of the same things. In short, absolutely start doing responsive designs.
  18. Here is the php force file download tutorial. http://amecms.com/article/PHP-Force-File-Download-With-File-Whitelist
  19. The DB can't decide what file extension to store the data in, you do that through your script or manually. Maybe you should post a screenshot of your db data in question. There are plenty of download scripts online but I can't seem to find a really good one at this moment. I may do a tutorial on this soon, so I'll post it back here when I do.
  20. Notice: Undefined variable: errorsoutput in /var/www/html/test/form.validation.php on line 124...138...152...166...180...194 You're still trying to check for it before it exists. You can add another isset() around the $errorsoutput. Also I realized, I don't think these vars will ever equal what you want cause you are getting this value from the foreach loop of $error. By the time the $errorsouput gets to the form fields it will only hold the last value the loop did. Is there a reason you need to have the error printed next to the form field rather than just above them all like normal. Typically when there is a error next to a form field it's generated by javascript not php validation. Not that is can't be done but it seems rather pointless to echo the errors twice.
  21. Honestly I don't know what you mean by "sticky form". The code you just posted doesn't really mean anything to us without seeing it in the whole context with the rest of the code around it, especially since you have changed things around while testing.
  22. Are you only storing the name and location of the file in the DB? The files themselves should be stored in folders like any normal file. Displaying a pdf in the browser is fairly easy but the others are much more complicated. Do you just need a link to be able to download the file to the clients computer? Please explain more of what you need and how things are setup.
  23. Those are cause you are trying to echo the var upon page load, they don't have any value until after you submit the form and even then it depends on if you throw any validation errors. You should use a isset() around them in the form and they will go away. But really there is no point for them in the form cause you are echoing them out in the validation area already.
  24. It's just an example to show the OP the result array from the glob();
  25. Well, most of this is redudnant and doesn't really work //if the fields are emptyprompt the user if (empty($fr_sd_ip) && empty($fr_sd_port) && empty($fr_protocol) && empty($fr_sd_app) && empty($fr_reason) && empty($fr_email)){ echo '<strong><b><font style="color:FF0000">All the fields with \'*\'are required.</font></b></strong>'; }else{ //check to see if any errors have been created //validate user input //creates an array of error variables and output /*$errormessage = array(); //if statements that will check each element of the form if(strlen($name) > 25){ $errormessage[] = 'Name is too long'; }else{ if($name = < 1){ echo "please enter a name." }*/ //Set the restrictions for each field so it may return a error //IP address if (!isset($fr_sd_ip)){ $error[] = $iperror; } //Ports if (!isset($fr_sd_port)){ $error[] = $porterror; } //protocol if (!isset($fr_protocol)){ $error[] = $protocolerror; } //application if (!isset($fr_sd_app)){ $error[] = $apperror; } //description if (!isset($fr_reason)){ $error[] = $reasonerror; } //email if (!isset($fr_email)){ $error[] = $emailerror; } The first part of that should be using || instead of &&. Why, bcause you're saying that in order to see the error all the fields have to be empty rather than just one or more. Then all the next checks you do are pointless the way you have them. Why, cause all the vars you are checking if are set, you already set so of course they will be set. Changing those to check for empty would be more correct but that still is not correct cause you are already checking them all for empty on the first check. Unless you plan on doing more specific validation per var, you only really need the first if() that is checking them all for empty. //if the fields are emptyprompt the user if (empty($fr_sd_ip) || empty($fr_sd_port) || empty($fr_protocol) || empty($fr_sd_app) || empty($fr_reason) || empty($fr_email)){ echo '<strong><b><font style="color:FF0000">All the fields with \'*\'are required.</font></b></strong>'; }else{
×
×
  • 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.