Jump to content

Jessica

Staff Alumni
  • Posts

    8,968
  • Joined

  • Last visited

  • Days Won

    41

Everything posted by Jessica

  1. header("Location: $_SERVER['HTTP_REFERER']"); You don't need those {}
  2. If I have the following string: $str = "This is a bunch of strings. String One: Test. String Two: Test Two." And I do this: $strings = explode("String", $str); The result is like this: $strings[0] = "This is a bunch of Strings."; $strings[1] = "One: Test."; $strings[2] = "Two: Test Two."; How would I keep the String on the front of the strings which have it. I can't just add String to the front of each line because the first entry does not have String on it. Help?
  3. you pretty much wrote it right there. What are you asking for? The sql? what type is the field? DATE, DATETIME, or INTEGER (storing timestamp)? if the first two, use php's date() function to format the date into this string: "Y-m-d" or "Y-m-d H:i:s" If it's integer, use time() then add three months to the date.
  4. Cookies can be easily edited. Plus, if someone steals the cookies of an allowed user (which is EASY to do), they now have access. If you want to use cookies, always check against the database and also store in a session and check that. Cookies aren't really that great because they are easily stolen and easily edited. "Further, since I am only checking if the cookie is set, but not any kind of value, can someone simply try vaious combinations of names and set them to any values on their hard drive and this will pass the test? " YES. Check the VALUES against the database at least.
  5. "require() and include()  are identical in every way except how they handle failure. include() produces a Warning while require() results in a  Fatal Error. In other words, don't hesitate to use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well." I use require because I never include things which are optional :)
  6. Why do you want to do this? You want to force them to slow down? :/
  7. It's called a CAPTCHA. Google that and you will find more info. I installed one today for someone, and I can do the same for you if you need.
  8. Probably has to do with my reusing the city variable. Try this: [code] function city($city,$location){   include('cities.php');   global $loc_pro, $loc_thug;   $info['pro'] = $loc_pro;   $info['thug'] = $loc_thug;   return $info; } [/code]
  9. And you've saved that file as action.php? I've had problems in the past with error reporting and using die. Try this and see if anything shows up. Otherwise, comment everything out and add lines back in until it stops working. That will show you the problematic line. [code] if(!is_numeric($age)){ print "The age is not numeric"; die(); } if(!ctype_alnum($name)){ print "Your name contained illegal characters"; die(); }[/code]
  10. Try this: [code] function city($city,$location){   include('cities.php');   global $loc_pro, $loc_thug;   $city['pro'] = $loc_pro;   $city['thug'] = $loc_thug;   return $city; } [/code] AFAIK: You can only return once per function, so what you had won't work. You might want to move this info into a database.
  11. Try this: [code] <html> <head> <title> Name test </title> </head> <body> Hi <?=htmlspecialchars($_POST['name'])?> <p> you are <?=intval($_POST['age'])?> years old!</p> <p><?php if($_POST['name'] == 'Harley'){     echo 'Hey champ! Welcome'; }else{   echo 'hi Stranger/Other, how are you'; } ?> </p> </body> </html> [/code] It works for me. What you had already also works on my server. *shrug*.
  12. No problem. Don't use books...books suck. Use the manual ;)
  13. You probably have a parse error. Post the new code.
  14. Edit: bool settype ( mixed &var, string type ) The type must be a string. "string" not string "int" not int http://us3.php.net/settype Look at the example.
  15. I think the Movable Type is doing stuff...it's rearranging them. Where is the actual query. It should look similar to: "SELECT * FROM tablename" MT should have an option to do this somewhere, you shouldn't need to mess with the code.
  16. onClick expects a javascript function. It looks like that is not what is there.
  17. Missing a ; [code]return $string;[/code]. If your page doesn't load, it can't compile.
  18. What's with this apostrophe? "; // 3.14 '              settype( $undecided, string );
  19. You made it more complicated than need be. [code] <?php if ($_POST['name'] == 'Harley'){     echo 'Hey champ! Welcome'; }else{   echo 'hi Stranger/Other, how are you'; } ?> [/code]
  20. thorpe, mind if I steal your signature? ;) I love that article.
  21. Change it to 1 instead of 0.
  22. [code]if (empty($_POST['password'])) {   $sql = "UPDATE users SET email = $email, area = $area, phone = $phone, age = $age, message = $message"; //EVERYTHING BUT PASSWORD } else {   $sql = "UPDATE users SET password = $password, email = $email, area = $area, phone = $phone, age = $age, message = $message"; //EVERYTHING INCLUDING PASSWORD }   mysql_query($query); [/code]You don't see a problem here? Your variable which contains the SQL is called $sql. Yet you're calling mysql_query with $query. You also need to add a WHERE or you'll update EVERYTHING, not nothing as was suggested above. You ALSO need to add some mysql error checking, and quote your strings which I forgot. Go read some more tutorials on mysql ;) [code] if (empty($_POST['password'])) {   $sql = "UPDATE users SET email = '$email', area = '$area', phone = '$phone', age = '$age', message = '$message'"; //EVERYTHING BUT PASSWORD } else {   $sql = "UPDATE users SET password = '$password', area = '$area', phone = '$phone', age = '$age', message = '$message'"; $message"; //EVERYTHING INCLUDING PASSWORD }   mysql_query($sql);[/code] Also what Shogun said was right. you have: [code]unset($_POST); $id = $_SESSION['userid']; if (empty($_POST['password'])) { }[/code] See a problem there?
×
×
  • 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.