Jump to content

php_tom

Members
  • Posts

    264
  • Joined

  • Last visited

    Never

Everything posted by php_tom

  1. Is your DB entry an integer? or a string? could you just use the string "NULL" for empty?
  2. http://tools.pingdom.com/fpt/?url=www.cutencuddly.org/letter/
  3. It would probably be easiest to do this server-side using PHP or another dynamic script. But you could do it with JavaScript string functions... see http://www.w3schools.com/jsref/jsref_obj_string.asp.
  4. It would 'work', but not secure... anybody could look at the page source and see <a href='viewtopic.php?t=12345' onClick='checkpassword("aPassword")'>aTopic</a> which would immediately tell them 1) what the password is, and 2) what URL to type in manually to see the topic Generally when doing password protection, it's best to do that server-side... Suppose a user has JavaScript turned off -- the password protection wouldn't work, they could see every topic! Most forums just allow users to PM each other instead of having passworded topics. That's my take on your code: if you don't want/need the site to be secure, your code is ok, but I really would try to get it more secure. Hope that helps.
  5. How about passing the screen size to the PHP script. I mean: <img src='' id='myImg' /> <script type='text/javascript'> var screenWidth = <whatever>; // Figure these out with your existing JS code var screenHeight = <whatever>; document.getElemenById('myImg').src = "image.php?sW="+screenWidth+"&sH="+screenHeight; </script> Then in 'image.php': <?php if(is_numeric($_GET['sW'])) $sW = $_GET['sW']; else $sW = 0; if(is_numeric($_GET['sH'])) $sH = $_GET['sH']; else $sH = 0; $cookie = "res=".$sW."x".$sH."&".$referrer; // setcookie(), GD image stuff, etc. ?> That's how I'd do it. But maybe not what you wanted... BTW, I think screen.width and screen.height don't work in IE... Hope that helps.
  6. That makes sense... I know browsers don't execute code in an image for security reasons, one option would be to use PHP to set the cookie stuff. What I mean is Inside image.php: 1) Set cookie info with PHP's setcookie() and $_COOKIE global 2) Then open the image URL w/ the GD lib, and stream it to the browser. In the page you want the image embedded, say <img src='image.php' /> Maybe that will accomplish what you want?
  7. Not sure if this is your problem, but the browser could be caching the image, only doing the cookie stuff the first time, then using the image in the cache. To test if this is the problem, try clearing your browser cache, then going to the page with the embedded PNG. It should set the cookie. Fixing this is easy, just change <img src="http://www.mydomain.com/counter.png" /> to <img src="http://www.mydomain.com/counter.png?t=<?php echo time(); ?>" /> Hope this helps.
  8. Are the alerts working for you? If the alerts are working, but it still subimts the form when its invalid, we need to see the form submission code. I would try something like <script language="javascript" type="text/javascript"> function valid(){ if(document.or.cust_name.value == ""){ alert('Customer name must be filled out.'); return false; }else if(document.or.add1.value == ""){ alert('Address must be filled out.'); return false; }else if(document.or.state.value == ""){ alert('State must be filled out.'); return false; }else if(document.or.city.value == ""){ alert('City must be filled out.'); return false; }else if(document.or.zip.value == ""){ alert('Zipcode must be filled out.'); return false; }else if(document.or.p_name.value == ""){ alert('Project name must be filled out.'); return false; }else if(document.or.date.value == ""){ alert('Date needed must be filled out.'); return false; }else{ // The form is valid! Let's submit it... document.getElementById('myForm').submit(); } } </script> So this way, at the bottom of your form, you can have a button like this <input type='button' value='Submit' onclick='valid()' /> instead of <input type='submit' value='Submit' /> Hope this helps you...
  9. Seems to work for me... I get two images 'racing' on the screen, when they reach the other side, it redirects to 'won.php'. So I'm not sure what the problem you're having is. Maybe you need "var pos = new Array();" ?
  10. This is from http://www.quirksmode.org/js/events_properties.html:
  11. My understanding is that many popup blockers only stop popups that show up with no user action. But if you have your user click a link, then use javascript with onClick event, it shouldn't be blocked... If you're trying to get away from using JS, try <a href='whatever.php' target='TOP'>Link!</a> it should open a new window in IE, a new tab in FF. iframe wil only work if you're embedding HTML/PHP content in the page, like so: <iframe src='myPage.php'></iframe> If this all doesn't help you, post back explaining what you are trying to do.
  12. That will only give you a vertical/horizontal gradient, not a diagonal as LemonInflux said he wanted.
  13. That's something I've often wanted to do, just never had the time to figure it out... but you inspired me to do so . I think the only way is to do it in JavaScript. Check out the script I put together below, it basically makes a table where the BG color of each cell gradually shifts. Then your HTML code goes on top of that. Not pretty but it works. I tested it in FF, Opera, and IE6, not sure about other browsers, but it works in those. <html> <body style='margin:0px;padding:0px;'> <script> // Starting RGB color values, these should be 0-255. var startR = 100; var startG = 100; var startB = 100; // Ending RGB color values, these should be 0-255. var endR = 200; var endG = 200; var endB = 200; // How wide each gradient element box should be. Smaller number makes a // more seamless gradient, but takes longer to render. var grain = 15; // Here's the meat of the script: // 1) Get the window height and width var width, height; // Window dimensions: if (window.innerWidth) width=window.innerWidth; else if (document.documentElement && document.documentElement.clientWidth) width=document.documentElement.clientWidth; else if (document.body) width=document.body.clientWidth; if (window.innerHeight) height=window.innerHeight; else if (document.documentElement && document.documentElement.clientHeight) height=document.documentElement.clientHeight; else if (document.body) height=document.body.clientHeight; height = height-14; // 2) Write out a table with each cell's Background a bit different from the last. document.write("<table width='100%' height='100%' cellspacing='0' cellpadding='0'>"); for(var y=0;y<height;y+=grain) { document.write("<tr height='" + grain + "'>"); for(var x=0;x<width;x+=grain) { colorR = startR + Math.round((endR-startR)*(x+y)/(width+height)); colorG = startG + Math.round((endG-startG)*(x+y)/(width+height)); colorB = startB + Math.round((endB-startB)*(x+y)/(width+height)); color = "#" + dec2hex(colorR) + dec2hex(colorG) + dec2hex(colorB); document.write("<td width='" + grain + "' bgcolor='" + color + "' ></td>"); //if(x==y) alert((x+y)/(width+height)); } document.write("</tr>"); } document.write("</table>"); // A function useful for getting the hex color string function dec2hex(n){ n = parseInt(n); var c = 'ABCDEF'; var b = n / 16; var r = n % 16; b = b-(r/16); b = ((b>=0) && (b<=9)) ? b : c.charAt(b-10); return ((r>=0) && (r<=9)) ? b+''+r : b+''+c.charAt(r-10); } </script> <!-- Don't remove the following line! --> <div id='bodyText' style='position:absolute; top:0px; z-index:2; margin: 20px; width:97%;'> <p>The HTML of the page goes here...</p> <!-- Don't remove the following line! --> </div> </body> </html> Hope that helps.
  14. <script> var urls = Array(); <?php $res = mysql_query("SELECT * FROM bgimages"); $c = 0; while($row = mysql_fetch_assoc($res)) { echo "urls[$c] = ".$row['url']; $c++; } echo "function ChangeBackground(background) {"; echo "document.getElementById('myTableCell').style.backgroundImage = urls[$i];"; echo "}"; ?> </script>
  15. I think this will do what you want: <script type="text/javascript"> var dateStr = "09/04/2007"; var millis = Date.parse(dateStr); var newDate = new Date(); newDate.setTime(millis + 50 *24*60*60*1000); var newDateStr = "" + (newDate.getMonth()+1) + "/" + newDate.getDate() + "/" + newDate.getFullYear(); alert(newDateStr); </script> Hope it helps.
  16. Try this: <body> <script type="text/javascript"> function moveText(){ var tmp = document.getElementById("cell1").innerHTML document.getElementById("cell1").innerHTML=document.getElementById("cell2").innerHTML; document.getElementById("cell2").innerHTML = tmp; } </script> <table width="500" height="500" border="1" cellspacing="0" cellpadding="0"> <tr> <td width='50%'><div id="cell1">Text</div></td> <td width='50%'><div id="cell2"> </div></td> </tr> <tr> <td width='50%'><div id="cell3"> </div></td> <td width='50%'><div id="cell4"> </div></td> </tr> </table> <input type='button' onclick='moveText()' value='Move Text' /> </body> It switches the text in cell 1 to cell 2 and vice versa. Hope it's what you wanted.
  17. I don't want to write the code for you, but here's an example. <?php if($_GET['func']=='mail') { // Process the input $to = $_POST['to']; $from = "From: ".$_POST['from']."\r\n"; $subject = "Subject goes here"; $message = "Email message goes here"; if(mail($to, $subject, $message, $from) echo "Message successfully sent!"; else echo "Message could not be sent."; } else { // Print the form ?> <form action='ThisPage.php?func=mail' method='post'> Your Email: <input type='text' name='from' /> Send to: <select name='to'> <option value='person1@domain.com'>Person 1</option> <option value='person2@domain.com'>Person 2</option> <option value='person3@domain.com'>Person 3</option> </select> <textarea name='message'></textarea> <input type='submit' value='Send' /> </form> <?php } ?> Of course this code isn't highly secure... but it should do what you want.
  18. How did you add the CSS to the PHP file? Like this? <?php echo "<link rel='stylesheeet' href='myCSS.css' />"; ?>
  19. So I'd do this: $old_time = "2007-10-02 13:24:43"; list($date, $time) = explode(" ", $old_time); $date_arr = explode("-", $date); $time_arr = explode(":", $time); $hour = $time_arr[0]; $minute = $time_arr[1]; $second = $time_arr[2]; $year = $date_arr[0]; $month = $date_arr[1]; $day = $date_arr[2]; $stamp = mktime ($hour, $minute, $second, $month, $day, $year); I'm pretty sure this will work.
  20. This is a bit of work, but what I'd do is to make your columns TIME and DATE into one column STAMP which contains a timestamp (can be obtained by time() ). When somebody posts a reply to that topic, update the topic's stamp to time(). $ins = "INSERT INTO forum (TYPE,TOPICID,TITLE,DATE,STAMP) VALUES (2,...,'test post', ".time().")"; $upd = "UPDATE * FROM forum WHERE TYPE=1 AND TOPICID=... SET STAMP=".time(); Then just do SELECT * FROM forum WHERE type=1 ORDER BY stamp DESC to get get all topics in the order of latest reply. It's just how I'd do it, maybe there's another way... Hope that helps.
  21. Try var_dump($_SESSION) both in the page where you set the session vars, and in the next page where you try to access them again. Post the output.
  22. Did you get any errors? Also, did you remember to mysql_connect() and mysql_select_db() somewhere above the code you posted?
  23. Can you explain what this line does? I'm thinking that if "isset($TEMPLATE)" is always true, you would never call session_start(), so when you set the vars in $_SESSION they wouldn't pass through to the next page (if that made any sense). But maybe I'm wrong.
  24. I think you want: var Year = Hour * 24 * 365; Post back if it doesn't help.
  25. This works for me: <input type="button" value="Click Here" onclick="javascript:window.location.href='http://www.google.com'" /> But note that it's JS, you should have posted in the JS board. Hope it helps.
×
×
  • 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.