Jump to content

l4nc3r

Members
  • Posts

    82
  • Joined

  • Last visited

    Never

Everything posted by l4nc3r

  1. Hey man, along with anything you'd find with a plain ol' Google search, you can check out a series I wrote on quoting projects here: How to Create Accurate Quotes Pt. 1: Modeling Potential Projects The basic premise is you create a model for each project, create a time to complete the project from the model, and then multiply that by your desired rate. Also, even if you're learning as you go (which I still do for 90% of my projects), you need to do some research before hand to get a good idea of how long it's going to take you. Hope this helps! Tucker
  2. No need to complicate things with javascript, or even with posting to a separate script and then redirecting back. The way I usually do form validation is I have the action set to the same page and if the submit var is set I include the form validation file. So the way you would do it with multiple pages is, if the submit button is set, include the form validation file. If there is an error, do nothing and display the errors on the page. If there is no error, store the values in a session var and redirect to the next form page. So.. if(isset($_POST['submit'])) { include('formValidation.php'); if(!isset($error)) { $_SESSION['form'] = $_POST['value']; header('formPage2.php'); } } if(isset($error)) { echo $error; } // print out form
  3. I was trying to "actually help." You can't just post code, say it doesn't work, and expect to get helpful responses back. We need to know what your code is doing. If you followed the guidelines in that blog post, you could probably figure this out for yourself. That looks like fine output for $output. What does $obj print out?
  4. That's odd. Not really sure why echo doesn't work in that context. But why would you need it to? You can just echo out $i in the for statement.
  5. Including the file isn't enough--you have to call the function and echo out what it returns.
  6. Are PHP errors turned on? Did you check the source? Is it outputting HTML but you just can't see it? The function returns an output, it doesn't echo it automatically. When you use the function, are you using it like this? echo dynamic_checkbox_table(...);
  7. Use php tags, man. echo "<a href='".( strpos( '://', $row['website'] ) ? '' : '' ).$row['website']."' rel='nofollow'>".$row['website']."</a>\n";
  8. Gotta read those error messages, man. It says it's on line 84 in process_r.php where there was an unexpected "}". Generally, when you get an unexpected error, it means you forgot a semicolon in the line before it. include 'thank-you.php';
  9. You put all of your HTML inside of a variable. $content='';
  10. What error are you getting? What is $output equal to? What does the print_r on the $obj look like? When you're debugging, you have to know everything about your program. You want to know what every little variable is equal to and why it's acting the way it is. Post on my blog about it here.
  11. I'm assuming you're using an SQL dump to upload it. If that's the case, then you could just do one grand mysql_query() on the entire dump inside of a php script.
  12. You might've wanted to make it clear this was Drupal in the subject--I didn't know until I saw the "l" function, which I had to look up. Also, using $_REQUEST is a bad idea. You should change it to $_GET. So when you get data back from a database, it's ALWAYS in string form (unless you do prepared statements). So, with that in mind, the problem is in this code: if ($current_votes) { $new_votes = $current_votes + $value; db_query("UPDATE bonnier_vote SET votes = $new_votes WHERE nid = $nid"); } else { db_query("INSERT INTO bonnier_vote (nid, votes) VALUES ($nid, $value)"); } $current_votes is always going to return true (even if it's "0") because it's a string and therefore has value. What I think you want is this: $current_votes = (int)$current_votes; if ($current_votes + $value >= 0) { $new_votes = $current_votes + $value; db_query("UPDATE bonnier_vote SET votes = $new_votes WHERE nid = $nid"); } But that will only prevent it from going below 0. If you want it to, after it's been voted up and then down again to be prevented from being voted again, you would have to add some sort of check into the database. So when it's voted up, you would update the "voted" column to true for that vote. You'd allow it to go up and down, I'm assuming, as much as you want until it was 0 again and "voted" was true. Then no more voting would be allowed.
  13. Well, it should just keep moving through the code, so you could echo out some AJAX loader, run shell_exec, and in the line right after shell_exec do whatever. And so you know, shell_exec outputs the return from the command.
  14. Well, you should probably get learning those languages. You can't configure and edit a third party php script without knowing php. Check out this post on my blog for a good introduction to web programming and some places to find tutorials.
  15. The database variable is not in the scope of the function--it needs to be. Google php scope for more info on that. So you either have to make the database variable global, or use dependency-injection (meaning, pass the database variable as a parameter to each function). The latter is more pro.
  16. If it's a header why don't you just set it in the additional_headers parameter of the mail function?
  17. Cookies is one way. I'd prefer to store the "reads" in a database so I have access to that kind of data and if the user decides to clear his/her cookies, nothing is affected.
  18. Why are you worrying about passing session id's when they can easily be carried with cookies?
  19. Good questions. I recommend heading over to the manual and reading the section on sessions. My understanding of sessions is that only a session id is stored on the user's computer with cookies, and that id is sent to your php server to get any variables associated with it. So if your saving a username and password in session variables, the actual values are stored on the server. The only way a session id can be faked is if the user gets some other person's current valid session id, which is next to impossible. It IS therefore safe enough to set a $_SESSION['auth'] variable and counted that as authorized, instead of checking the username and password on every page. It's been a while since I've worked with AJAX and sessions, but I'm fairly sure that sessions are maintained even when an AJAX request is made to them. If on the page you're making a request to you just add a if(empty($_SESSION['auth'])) { redirect... } you'll be fine and no one will be able to hack it. If they ARE authed, be sure to make the necessary checks on the POST data to make sure it's in the form you want it to be in. If either that or the auth fails, you can have the php script your requesting send back an error message to be output.
  20. Ahhh, I've used the Google Maps API quite a bit. I'm not sure how much you know about the web programming world, but if you're new to javascript, that'll be an absolute must if you want to use the Google Maps API. So check out a tutorial on tizag.com or w3schools.com If you're interested in doing this project right, I'd recommend learning the MooTools javascript framework and developing your code in OOP. But that's advanced and not really necessary if you're a beginner to this stuff. It is easier to code with, though, once you get the hang of it. If/when you've got javascript down, check out the Google Maps API V3 (V2 was recently deprecated). Get an API key/install it and then open up the developer's guide. For updating the map dynamically when the user interacts with the form, add an event listener to the form (onSubmit, for example) and tie it to a function that'll update the map. The icons that would represent his office locations are called "markers"--they're in the developer guide.
  21. What is the problem, exactly?
  22. You need a javascript redirect. http://www.tizag.com/javascriptT/javascriptredirect.php
×
×
  • 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.