Jump to content

cosmic_sniper

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Everything posted by cosmic_sniper

  1. I'm not so familiar with CSS but I'm formatting the table using attributes on every HTML tag. You mean using include() as a body of mail()? Did I get it right?
  2. Thanks for the response. It's nice that you pointed that out but I think (I'm not sure though) that would be applicable only if I would encode the output directly on the email. What I'm looking for is some sort of code that would allow users to copy-paste the output as it is (with the alignment) or better yet, a code that would directly email the output. One option might be the use of mail() but if I got it right, using that, the body of the email could only contain up to 70 characters which is a great limitation on my part.
  3. thanks CPD for raising about filter_var I found it in another tutorial and I'm now studying about it.
  4. Thanks for the advice. I tried this online sitemap generator wherein you just need to give the website and they would give you a download link for an xml file which you would upload into the root directory of your site. In that case, is it safe to say that the file is only good for the sitemap applicable during the time the xml file was generated and I have to generate another sitemap whenever I change factors concerning the link?
  5. I was trying to index my website on Google and I came across "sitemap". To be honest, I've heard of the term before but don't really understand it. After conducting a few research I had better understanding of it and decided to create Sitemaps for my sites. The problem is I only know HTML (pretty good understanding) and PHP (on the process of studying). If I got it right, sitemap in accordance to sitemap protocol is created using XML. I came across one option, which is using third-party software. Do you think it's a good option? If so, then do you have any suggested software? Or should I really learn to create a sitemap manually? A little off-topic question: how long does it usually take for google to crawl into the site for it to see the keywords, etc. Thanks in advance!
  6. If I got it right, type casting would force the system to understand that a certain string / variable is of a certain data type specified. As you've said it's not checking, per-se. Though it would be very helpful if I can make the form accept specific data types. If that would be the case, then there won't be a need for checking in the first place. lol ??? (completely puzzled) I'm sorry xyph but I really didn't get you there. I'm new to programming and self-studying, applying concepts as I learn them. Unfortunately, RegEx is about 8 lessons from where I am now. If it's not too much of a bother, could you help me construct that expression into if()? Finally, something I can work out with my current skills. Thanks for bringing this up but what is the function that I can use to check if the first character is "-"?
  7. It seems that you designed your page for widescreen display. Though relatively few, there are still square monitors (like the one I'm using now). For such sites user experience should be put in the core of the design (I've learned from a Facebook developer.). Scrolling sideways is a bit inconvenient and may cause "one link to go down then another follows" (from The Social Network) So the bottom line is adjust page width to accommodate square monitors.
  8. Nice work you have there! First thing that caught my attention was the button which says "Choose Music". So what got into my head was, "Hey, let me check some music." Then it turned out that it was to upload a music. I would suggest changing the terminology used. Make it "Upload Music" That would be it for now.
  9. I am using that script to check for values entered on a form. Here's the code of the form: <html> <body> <form action="calc.php" method="post"> Date of transaction: <select name="month"> <option>-Month- <option>01 <option>02 <option>03 <option>04 <option>05 <option>06 <option>07 <option>08 <option>09 <option>10 <option>11 <option>12 </select> <select name="day"> <option>-Day- <option>01 <option>02 <option>03 <option>04 <option>05 <option>06 <option>07 <option>08 <option>09 <option>10 <option>11 <option>12 <option>13 <option>14 <option>15 <option>16 <option>17 <option>18 <option>19 <option>20 <option>21 <option>22 <option>23 <option>24 <option>25 <option>26 <option>27 <option>28 <option>29 <option>30 <option>31 </select> Time:<select name="hr"> <option>-hr- <option>01 <option>02 <option>03 <option>04 <option>05 <option>06 <option>07 <option>08 <option>09 <option>10 <option>11 <option>12 </select> <select name="min"> <option>-min- <option>00 <option>01 <option>02 <option>03 <option>04 <option>05 <option>06 <option>07 <option>08 <option>09 <option>10 <option>11 <option>12 <option>13 <option>14 <option>15 <option>16 <option>17 <option>18 <option>19 <option>20 <option>21 <option>22 <option>23 <option>24 <option>25 <option>26 <option>27 <option>28 <option>29 <option>30 <option>31 <option>32 <option>33 <option>34 <option>35 <option>36 <option>37 <option>38 <option>39 <option>40 <option>41 <option>42 <option>43 <option>44 <option>45 <option>46 <option>47 <option>48 <option>49 <option>50 <option>51 <option>52 <option>53 <option>54 <option>55 <option>56 <option>57 <option>58 <option>59 </select> <br> Type of transaction: Buy<input type="radio" name="transaction" value="buy">Sell<input type="radio" name="transaction" value="sell"><br> Stock symbol:<input type="text" name="stock">(e.g. AB, SCC, ABS)<br> Book value of stock:<input type="text" name="BV">(<i><b>*For selling transaction only</b></i>)<br> Price per share:<input type="text" name="price"><br> Volume of shares:<input type="text" name="volume"><br> <input type="submit"> </form> Here are the things I want to check: Are necessary fields filled out? Did the user enter the proper data type? I'm almost done with the first item. The only thing left is to check for the date and time section. I guess (please correct me if I'm wrong), the following code would check if the data passed is a number and not the default "-day-" or "-hr-" <?php if ($month >= 0 && $day >= 0 && $hr >= 0 && $min >= 0) { $checkpoint = 'false'; } else { echo '<font color="#FF0000">Date and time is not properly set.</font>'. '<br />'; $checkpoint = 'true'; } ?> For the second bullet for checking, what code can check if the data entered is a float for field that requires it or long for field that requires it?
  10. I finally got it to work by introducing a new variable. Thanks as well for the comments since it somehow helped me arrive at the solution. Here's the code: <?php // checking of variables if (!isset($transaction)) { echo '<font color="#FF0000">Type of transaction is not set.</font>'. '<br />'; $checkpoint = "true"; } else { if ($transaction == 'sell') { if (empty($BV)) { echo '<font color="#FF0000">Book value is not set.</font>'. '<br />'; $checkpoint = "true"; } } } if (empty($stock)) { echo '<font color="#FF0000">Stock symbol is not set.</font>'. '<br />'; $checkpoint = "true"; } if (empty($price)) { echo '<font color="#FF0000">Price per share is not set.</font>'. '<br />'; $checkpoint = "true"; } if (empty($volume)) { echo '<font color="#FF0000">Volume of shares is not set.</font>'. '<br />'; $checkpoint = "true"; } if ($checkpoint == "true") { echo '<br /><br /> Go back and fill out necessary fields.'; } else { echo 'Copy and paste the following in the email that you would be submitting.'. '<br /><br />'; switch ($transaction) { case 'buy': include('calc_buy.php'); break; case 'sell': include('calc_sell.php'); break; default: echo '<font color="#FF0000"><b>If you see this message there is something wrong with your session. Please send us a feedback with the details of your session before seeing this message.</b></font>'; } } ?> This is already working. Though, there is still another problem regarding checking of values. I'll post it in my next reply. Edit: Included <?php ?> on code.
  11. I do understand that the way I used if() in that code is wrong. If I got it right, the way it should be nested is something like this: if (condition_a) { if (condition_b) { echo 'condition_a and condition_b are TRUE'; } else (condition_c) { echo 'condition_a and condition_c are TRUE'; } } elseif (condition_d) { echo 'condition_a is FALSE and condition_d is TRUE'; } elseif (condition_e) { echo 'condition_a and condition_d are FALSE and condition_e is TRUE'; } else { echo 'condition_a, condition_d, and condition_e is FALSE'; } ?> I'll explain it from the start and how I came up with that code. What I wanted is to check for certain conditions, then if any of those returned TRUE, echo something then end the program. If none of the conditions are true, continue with the next section. With the structure of if...elseif...else(), I can only check for one condition that is TRUE. For nested if(), like the case of condition_b & c, I can only check for them if a is correct. So, to check all the conditions, I used a series of if(). (checking successful ) Here's the problem. With such code (series of if()), even the conditions returned TRUE, the succeeding section would still execute. That's how I came up with if( if() { //code } if() { //code } if() { //code } } { else { //code } Now I know that it would not work. Any suggestion for alternative ways to do it?
  12. I would like to have a script that would check certain parameters and if none of them returns TRUE, execute a set of codes. So the idea is somehow like if...else(). <?php // trying to put if() directly within if() if ( // checking of variables if (!isset($transaction)) { echo '<font color="#FF0000">Type of transaction is not set.</font>'. '<br />'; } else { if ($transaction == 'sell') { if (empty($BV)) { echo '<font color="#FF0000">Book value is not set.</font>'. '<br />'; } } } if (empty($stock)) { echo '<font color="#FF0000">Stock symbol is not set.</font>'. '<br />'; } if (empty($price)) { echo '<font color="#FF0000">Price per share is not set.</font>'. '<br />'; } if (empty($volume)) { echo '<font color="#FF0000">Volume of shares is not set.</font>'. '<br />'; } ) { echo 'Go back and fill out necessary fields.'; } // if none of the above parameters returns TRUE else { echo 'Copy and paste the following in the email that you would be submitting.' </tr> <tr> <td> switch ($transaction) { case 'buy': include('calc_buy.php'); break; case 'sell': include('calc_sell.php'); break; default: echo '<font color="#FF0000"><b>If you see this message there is something wrong with your session. Please send us a feedback with the details of your session before seeing this message.</b></font>'; } } ?> This code returns an error and as I understand the error, it is because of if (if ()). How can I make it work? Thanks in advance!
  13. Thanks it worked! Though, I made a little tweaking in able to incorporate number_format() that I need. <?php if($CG < 0) { $CG *= -1; echo "(". number_format($CG, 2, '.', ','). ")"; } else { echo number_format($CG, 2, '.', ','); } ?>
  14. Aside from money_format(), is there another way to use "()" instead of "-" for negative numbers? Actually, using money_format() would be best for me but I've read somewhere that list of locale differ from server to server. Unfortunately, I cannot identify the list of locale supported on the server I'm using (Heliohost) since system('locale -a') is disabled. Thanks in advance!
  15. Well I guess this is really such a big debate. Intellectual rights on software or even websites would not really give you protection as it should be but it would just help you project yourself as a "big fish" as joe92 said.
  16. How can I keep the alignment of the table when the data is pasted on an email? The output of the table is intended to be copied and pasted on an email on an external sever (e.g. yahoo, gmail). The problem is whenever the output is pasted on the body of email, it is distorted. It loses rows and column separations. I am thinking of two ways to solve this (I don't know if these are possible.) Apply some formatting to the table so that it would maintain it's alignment. Use a code to make the output show directly to the body of a third party email service. If the second option is possible, then it would be very great since the whole table intended to be sent through email is a separate file that is displayed using include(). Is there a way to achieve such a thing? I hope I explained my idea clearly. Thanks in advance.
  17. I am wondering if there's such a thing as intellectual right on software / application? I mean, if you have an idea and put it into codes, applied for a patent (if there is) then release it, then you could say you own it. But what if someone adopted your idea, changed the design, and used a different code? It is clear that the idea is yours but will your patent still give you protection in such a case? So if ever there is such thing as intellectual property right on software / application, is there a point applying for such patent, especially ideas could be interpreted using different codes? What do you guys think?
  18. GiGalo, I don't fully understand how to use the code? Should I replace the values used for every image that I work on? Or should I call unto the script? How? Sorry if kinda dumb question. . . complete newbie here.
  19. Well, the reason why I intend to do it using a script is for it to be more convenient and easier to maintain. The website I'm working on has quite a number of images on it and these images would be reflected on different pages with different size that would be needed. In addition to that these images are being updated / replaced from time to time. So, having a single image file and a script that would manage the size of the image would be great. But since you pointed it out, I think having a PHP script with such access (access beyond web-root) is the reason why it's not working on the server. I'm using a shared hosting service which prevents such access (necessarily). Is there any other script that might be able to achieve the goal that I wanted or do I really have to resort to saving multiple files?
  20. I would be needing different picture sizes on different pages on my site but saving different sizes of a single pic is space consuming. I've heard that it's possible to automatically adjust the size of the picture and found a script that ought to make that possible. Unfortunately, it did not work for me. Article: PHP Thumbnail Script Using GD http://www.rainbodesign.com/pub/thumbnails/ Here's the code: <? // Rainbo Design PHP Thumbnail Maker // Copyright (C) 2005-2010 by Richard L. Trethewey - rick@rainbo.net // All Rights Reserved // If you use this script, I'd appreciate a link! // http://www.rainbodesign.com/pub/ // Defaults $thumbsize = 150; // Default thumbnail width. $imagesource = 'images/default_img.jpg'; // Default image file name. // Set to empty string for no image output on failure. $error = ''; if (isset($_GET['width'])) { $thumbsize = $_GET['width']; } if (isset($_GET['src'])) { $imagesource = $_GET['src']; } $filetype = substr($imagesource,strlen($imagesource)-4,4); $filetype = strtolower($filetype); if (file_exists($imagesource)) { if($filetype == ".gif") $image = @imagecreatefromgif($imagesource); if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource); if($filetype == ".png") $image = @imagecreatefrompng($imagesource); $imagewidth = imagesx($image); $imageheight = imagesy($image); if ($imagewidth >= $thumbsize) { $thumbwidth = $thumbsize; $factor = $thumbsize / $imagewidth; $thumbheight = floor($imageheight * $factor); } else { $thumbwidth = $imagewidth; $thumbheight = $imageheight; $factor = 1; } // Create a thumbnail-sized GD Image object $thumb = @imagecreatetruecolor($thumbwidth,$thumbheight); // bool imagecopyresized ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h ) imagecopyresized($thumb, $image, 0, 0, 0, 0, $thumbwidth, $thumbheight, $imagewidth, $imageheight); // Send output to user as a jpeg type, regardless of original type header("Content-type:image/jpeg;"); imagejpeg($thumb); imagedestroy($image); imagedestroy($thumb); } else { $error = "File $imagesource Not Found"; } // endif file_exists if ($error != '') { header('Content-type:text/plain;'); echo($error); exit; } // endif $error ?> And here's a little instruction (which I have followed as well). Can anyone please help me with this script or something similar? Thanks in advance. Edit: The problem is that the image is not showing. It appears as if it cannot locate the file source.
  21. Oh yah Psycho. You did bring that up already. Sorry to miss that specific point. My thoughts were kinda diverted on explaining my the structure that I want. Regarding the use of swithc() statement, thanks for mentioning that. It's just that I have fixed the codes before I read your response but I totally believe in what you said that switch() statement is more appropriate for this. I would be revising my code using that. Thanks.
  22. Thanks for the help! That finally made my day. I should have known it all along that the form name is not posted along with the content of the form. That hidden input is the "missing variable" that I've been looking for. Thanks for bringing that up. I finally get things to work the way I want it. But just in case another newbie would be reading this thread, I would like to bring up one significant factor that made it work. After adding the <input type="hidden" name="consistent_name_across_sources" value="varrying_value_across_sources">, it is necessary to use == instead of = in the if() and elseif() statements. That made it work for me. I have an idea on why it is so but I believe that other guys here are in better position to explain it. After all, mine was just an educated guess and not substantially acceptable fact. Thanks again
  23. What I'm actually trying to do in the code is first identify the source of data. So since there are four different files pointing towards output.php and the data would all be coming from a form, i decided to name each form as a, b, c, d respectively. That is why I assigned $form_name = $_POST['a'] (the name of form from step2_a.php) then I intend to set if() statement to validate if the request really came from step2_a.php. If not, then it might be from other forms and that's where elseif() comes in. I tried to use "is identical" to replace "is equal to" to check further check the interpretation of the code. Then after execution, the if)_ statements turned to be false (most probably due to the reason you have explained). Comparing it with the initial "is equal to" assignment, where it does not return false on every if() argument. From there, I've learned that the code does not actually identify it that way. (mostly a self-help to understand how it language runs) Anyway, the bottom line is, I want the code to identify the source of the data and execute the corresponding set of commands. I hope this helps to explain how I intend it to be structured.
  24. Hi there, First of all, I want to present the diagram that I'm working on. ----------- Diagram ----------- step2_a.php --| step2_b.php --|---> output.php step2_c.php --| (Process is included here) step2_d.php --| and here are the corresponding codes: step2_x: . . . <form action="output.php" method="post" name="a"> req1: <input type="text" name="a_req_1"> req2: <input type="text" name="a_req_2"> . . . <input type="submit"> </form> ------ . . . <form action="output.php" method="post" name="b"> req1: <input type="text" name="b_req_1"> req2: <input type="text" name="b_req_2"> . . . <input type="submit"> </form> . . . . . . output.php: <?php $form_name = $_POST['a']; if($form_name = "a") { //variables for a goes here //code goes here } elseif($form_name = "b") { //variables for b goes here //code goes here } elseif($form_name = "c") { //cariables for c goes here //code goes here } elseif($form_name = "d") { //variables for d goes here //code goes here } else { //code goes here } ?> Now, here's the problem. output.php always sees the primary condition as true. Even the data came from step2_b, the code does not recognize it. I tried to use "==" instead of "=" but the code sees the arguments as false so it executed the code on "else". How can I make the code distinguish the source of the data so that it would execute the right set of commands? Thanks in advance.
×
×
  • 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.