Jump to content

fortnox007

Members
  • Posts

    783
  • Joined

  • Last visited

    Never

Everything posted by fortnox007

  1. $mysqli = mysqli_connect("serveraddress", "user", "pass", "DATABASENAME");
  2. also you have a paragraph in front of your body tag and if i am correct thats a no go <p><body>
  3. Ah I thought so than it would make sense to add an extra column as a game id, that way you can fetch all the rows with a certain game id. because now this 531 ID makes no sense at all. Ones you done that, you can do <?php include('connection-file.php'); //connection stuff if(isset($_GET['id'])){ $query_var = (int)$_GET['id']; // force it to be an integer $query = "SELECT * your_table WHERE gameID = '$query_var'"; $result = mysqli_query($dbc, $query); while($row = mysqli_fetch_array($result)) { //this output should be filtered in a real world echo '<h2>TITLE: '.$row['title'].'</h2><br />'; echo 'some flash object here with the right variable'.$row['swfname'].'<br />'; echo '<h3>How To: '.$row['howto'].'</h3>'; } }// I forgot this last bracket ?> if you want to limit the rows use LIMIT 1 for instance in your query at the end. -edit: it could be nice to add some 'else - clauses' for instance if someone types ?id=lalalala (int)$_GET['id'] will become 0.
  4. Uhm just for my sense, what is the relation of the get variable ( 531) and the stuff in the database? is it a game id?
  5. put (int) before $id, also hidden fields can be altered and you certainly don't want that to happen. with (int) you force it to be an integer, which i am pretty sure $id is.
  6. don't forget to sanitize like shown in pretty much every script above
  7. here you go: http://www.w3schools.com/sql/sql_groupby.asp
  8. here you go I had some time left, this script works as long as you name it with .php in the end. for instance monkeys.php your client numbers are hard coded not the best option, but for a free script it might be useful for you. good luck with your fitness website <?php session_start(); ?> <!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" xml:lang="nl" lang="nl" > <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>My first fitness website ;-)</title> </head> <body> <!-- form here --> <?php //clients hardcoded instead of a database $my_clients = array( '123456', '234567', '345678' );// you can add a number they should be seperated by comma's //check if client exists if(in_array($_POST['id'], $my_clients)){ $valid = 1; }else{ $valid = 0; } //default text in box $id = 'xxxxx'; //default text in id box. if(isset($_POST['submit'])&& $valid===1){ $_SESSION['client_id']= $_POST['id']; $id = $_SESSION['client_id']; } ?> <div id="login" style="background:#666666; position:absolute; top:0; right:0; z-index: 1000; width:150px; overflow:visible; border:1px solid #999999;"> <form action="" method="post"> <ul style="text-align: right; list-style: none;"> <li><input type="text" name="id" value="<?php echo $id; ?>" /></li> <li><input type="submit" name="submit" value="submit" /></li> </ul> </form> </div> <!-- en form --> <!-- just some bogus list with links --> <div> <ul> <li><a href="http://examplepage.com/<?php echo $id;?>">examplepage.com/<?php echo $id;?></a></li> <li><a href="http://anypage.com/<?php echo $id;?>">anypage.com/<?php echo $id;?></a></li> <li><a href="http://blablabla.com/<?php echo $id;?>">blablabla.com/<?php echo $id;?></a></li> </ul> </div> <!-- end bogus list --> </body> </html> -edit: in this case only the numbers 123456, 234567,345678 work
  9. aren't the headers already sent after you echo out?
  10. I bet it can be found here: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html month() or monthname() i think
  11. I learned a bit from W3schools.com/php Also read some books. Hope that helps and that script should be put on top of a .php file (so not a .html file)
  12. well, I guess what you could do is: on top of update.php get the post variables and place them in a new update query. // I would not let them change the ID i bet its a auto incrementing primary key right? //start update.php if (isset($POST['submit'])&&!empty($_POST['title'])&&!empty($_POST['text'])&&!empty($_POST['number'])){ $ID= (int)$_POST['ID']; $title = mysqli_real_escape_string($_POST['title']); $text = mysqli_real_escape_string($_POST['text']); $number = mysqli_real_escape_string($_POST['number']); $query = "UPDATE yourtablename SET title = '$title' SET text = '$text' SET number ='$number' WHERE ID = '$ID' "; }else{ echo 'you need to fill in all fields'; //maybe even output form here again or make a redirect to the form with a error message. }
  13. You don't have any error reporting in your database query, I would also add, Limit 1 since i guess there can be only 1 user. But on the other hand, if your passwords are hashed, all you get back is a hash. I am not sure if you ant that and if it would be better for them to just set a new password and email it to them.
  14. lol well those are interesting websites, about fitness aren't they? Well i think there are a few ways to do this and i certainly would store the id's in a database (and not a textfile) and perform a check on that. anyway a small example of this by using sessions without any checks: a simple redirect can be done like this: (without any checking for the id in a database) <?php session_start(); // put this on top of you file above <html> //if clause checking if ID is set. if (isset($_SESSION['special_id'])){ header("Location: http://www.example.com/$_SESSION['special_id'].php"); }else{ header("Location: http://www.example.com/errorpage.php"); } ?>
  15. why not also use an unordered list instead of a billion div's
  16. not sure if this is helpful, but is your primary key set on auto increment?
  17. fortnox007

    ....

    <?php echo base64_decode('SEFwcHkgbmV3IHllYXIgbGFkcyEgQ2hlZXJzIEZvcnRub3gwMDc='); ?>
  18. just apart frm that i would add another table named category (like weekly monthly children elder etc) that way in the end you can out put everything in nice categories. back to your thing. I think this is what you are looking for: ie. SELECT table1.column1, table2.column2 FROM table1, table2 WHERE table1.column1 = table2.column1; source: http://articles.techrepublic.com.com/5100-10878_11-1050307.html -also nice for people to make a category first. so you first show them the existing categories, and give thme the opportunity to add one which is ofcourse pretty simple (ID, category_name, category_description)
  19. I see, thanks for that extra bit of info on the parsing, never knew that, but glad i accidentally had a good practise
  20. maybe put ' ' around the $_POST elements $_POST['phone'] instead of $_POST[phone] et cetera
  21. don't you just accidentally mean the pre tags <pre></pre> http://www.w3schools.com/TAGS/tag_pre.asp
  22. don't forget to filter $PHP_SELF http://www.phpro.org/tutorials/PHP-Security.html
  23. i can use it hehe : thank you -edit: your .htaccess file is blocking the example page
  24. I just found a short example here for php, seems pretty awesome certainly the rollback function. omg i learned a lot today -edit:lol forgot to post it: http://articles.techrepublic.com.com/5100-10878_11-6085922.html
  25. cool i am going to test that out thank you! I hope i can make it in OOphp style. Ones I know how to program that way. ill post it if someone finds it useful.
×
×
  • 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.