Jump to content
MakeWebGames

Script47

Members
  • Posts

    1,150
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Script47

  1. Good point, I just thought I would explain it all. Thinking about it I probably should have just told him this haha. Got to love IMGTFY. :p
  2. Open PMA Click on the DB you're using Then on the `users` table Look on the top where it has all the control links Click "Operations" or something like that Look for something which says auto increment change it will have a number in it Change it to what you want   [ATTACH=CONFIG]1271[/ATTACH] [ATTACH=CONFIG]1272[/ATTACH] I emptied table, why does the ID still come out as that? Because all you did was clear the data from the table, meaning you never changed the A_I value. How should I clear a table and change A_I value? In the future you should Truncate the table instead, that removes all the data and changes increment back to 1. [ATTACH=CONFIG]1273[/ATTACH]
  3. There has recently been loads more of these damn threads.
  4. Script47

    Vital End

    No idea what it is, I don't thing many others do?
  5. Sorry, forgot to say, this link helped me fix it. Thanks.
  6. PHP Documentation Tizag W3Schools Good luck mate.
  7. I like this, it lets you customise it quite a bit.
  8. I try my best! ;) What I was going to say is make I so you press keyboard numbers and type like that. Granted it will require you to get key codes (like they do in Java) and log the buttons pressed but it would make it neat. Any plans on future projects?
  9. I checked it out yesterday it's a lot sweeter, with the new jQuery effects. He also changed the looks BTW and made it look better.
  10. *Quote removed, due to relevant posts being deleted for being irrelevant. ~ DJK. Back on topic, maybe this is the reason?   if ($found) return sprintf("[img=/images/roulette.png]", $found['name'], $found['name']);   Seems like the creator intended BBcode to be used? Just change it to normal HTML img tags and it should be fine.
  11. Script47

    2013... 2014

    Complete current projects Learn another programming language e.g C#, Java
  12.   So how exactly is it outdated? Maybe you used the wrong word?
  13. I actually just used this, and I have to say it is very neat. Great job man.
  14. I explain what they do in the comment blocks in the actual code. :p   I put it at the top in bold saying the formatting got messed up when adding it to this site.   Yep, it is. You'd need it to be honest. You see why I'm annoyed here? Everyone stays on topic yet you just can't do that can you. Off-topic, my 400th post! :D
  15. I'll be honest, I thought exactly the same thing I was going to post but thought leave it. Now I'm wondering if staff could close it, as it's a pointless thread where each person will keep complaining.
  16. I made this tutorial a while back, any feedback will be helpful. Slight problem with the code, it lost all it's formatting hence it's all on one side.   [align=justify]So, you want to learn HTML & PHP, and you're serious about it. Firstly I just want to clarify in no way do I think I am a professional programmer/coder. However I can with confidence say I am decent. So if I make any mistakes point them out and I will change it. Without further ado let's get to it! [/align] [align=center]Table of contents [/align] [align=center] Overview of PHP Simple form using HTML & PHP Guess the number game [/align] [align=center]Overview of PHP [/align] [align=justify]PHP stands for Hypertext Pre-processor; PHP is widely used and probably the most popular server side language used. It is a powerful language if you would like to make dynamic and interactive web pages quickly. Once you know what you are doing with PHP you will find it a fun language to use. But obviously you must learn the basics before you actually want to make big sites. Hopefully that is what I'll be helping you with in this tutorial. Now that's the "Overview" done so we can get with the coding now! [/align]:D [align=center]Simple form using HTML & PHP [/align] [align=justify]So what you'll want to do is download an IDE like Netbeans for PHP or PHPStorm, type one of those in to Google and open them once you have downloaded, create a new project call it what you wish then create a file called index.php, and write the following code: [/align]   <html> <head> <title> Simple forms PHP & HTML </title> </head> <body> <form action="submit.php" method="post"> <input type="text" name="Name" placeholder="Write your name here!" title="Write your name here!" required="true" spellcheck="true"> <input type="submit" value="Submit!"> </form> </body> </html>   [align=justify]Okay so now save that file and open it using a web browser and if you are successful you should see a text field and a simple submit button. So I will explain the code which I think may need explaining. action="submit.php" - the page (URL) you want to process the users input. method="post" - the way you send form data. placeholder="Write your name here!" - default text that appears in the text field that tells people what to write in that field. title="Write your name here!" - text that appears when you hover over the text field with your mouse. required="true" - this is some client side "checks" to make sure the field has something inside it. Now create a new file called submit.php, this will be the file which the users input is processed to after they click the submit button. The PHP part so either copy & paste this code in to the new file or type it up. I have commented out the code. So what are comments? Comments are used to annotate a script to help people understand what's going on in it. How do you comment? You can use the single line comment for short comment, to use them do this: // Hello, this is a comment, a single line comment to be precise! You can have block comments (multiple line comments) too. You will it all in the next piece of PHP code I share. [/align]   <html> <head> <title> Simple forms PHP & HTML </title> </head> </html> <?php /* * Page created by: * User: Script47 * Date: 16/09/13 * Time: 17:55 */ /* * Checks if the data "Name" is NOT set and checks to see if it's empty using an if-else statement. * If it is empty it will give the error ELSE it will do the other part we told it to. * As you see we are using HTML tags in PHP code it's is possible to do so. * So what does echo do? echo is used to output text, mess around with it it's very simple use it like this: echo 'Hello'; OR echo "Hello"; * So what does exit(); do? That tells the PHP script to stop running the script and we don't want it to run if the Name field is empty so we kill the page. * So what does header(); do? In this case it will refresh the page after two seconds and redirect the person back to the index page. */ if (!isset($_POST['Name']) || empty($_POST['Name'])) { echo '<br/>'; echo 'You left the Name field empty!<br/>'; header("Refresh:2; URL=index.php"); exit(); } else { /* * Create a variable; what is a variable? A variable holds data; let that be an integer, text, decimals or anything else. * How to create a variable, a variable is made by putting the "$" dollar sign then the variable name in our case it's called, $Name. * Variables are case sensitive, so $Name is not the same as $name. * $_POST['Name'] contains our users input so we say $Name = $_POST['Name'] which could be bob or anything else but by using a variable we can let the user have any name and store it in that variable. * However, you never trust users input as your site could get hacked, XSS'd, read up on that more. So what we do here is use the function htmlspecialchars() on $_POST['Name'] which hold our users input. * What does htmlspecialchars() do? It transform any HTML code in to it's entities. So this "<" becomes this "<". */ $Name = htmlspecialchars($_POST['Name']); echo "Hello " . $Name . ", how's it going?"; exit(); }   [align=justify]This is how you make a simple form and pass data through it. Now that you know the basics we can make a little fun game, it was one of the first things I made. A little guess the number game! Okay so we need to plan the game out first. We need to plan the stages of development and consider some things. I will list the things we need to consider but before that you try think of the things we'll need to think about (a little challenge). The minimum and maximum number we wish to allow to be randomly outputted. Validating user input i.e. Checking if field is empty, checking if a number is actually passed through and nothing else, securing the input. Success & failure messages if number guessed is right or wrong. Now create a new project folder in your IDE or in the editor you are using and make a project called Guess the number. Inside it create a file called index.php (the first page the user will see). Note I won't explain the HTML and the PHP that we have already gone over! [/align]   <html> <head> <title> Guess the number</title> </head> <body> <center> <br/> <br/> <form action="guess.php" method="post"> <input type="number" name="guessedNumber" placeholder="Number between 1-100!" title="Number between 1-100" required="true"> <input type="submit" value="Guess!"> </form> </center> </body> </html>   [align=justify]That is our simple HTML code, a simple form with a submit button. Now swiftly on to the PHP (server side). So create a new page called guess.php and write the following code inside it.[/align]   <html> <head> <title>Guess</title> </head> </html> <?php echo '<center>'; if (!ctype_digit($_POST['guessedNumber'])) { echo '<br/>'; echo 'Input value has to be an integer!<br/>'; header("Refresh:2; URL=index.php"); exit(); } if (!isset($_POST['guessedNumber']) || empty($_POST['guessedNumber'])) { echo 'Input field empty!<br/>'; header("Refresh:2; URL=index.php"); exit(); } else { $guessedNumber = htmlspecialchars($_POST['guessedNumber'])+0; $randomNumber = rand(1, 100); if ($guessedNumber === $randomNumber) { echo 'Woohoo, you guessed right!<br/>'; echo 'Random number was: '.$randomNumber. '<br/>'; echo '<a href="index.php">Play again?</a>'; exit(); } else { echo 'Aw snap, unlucky better luck next time!<br/>'; echo 'The actual answer was: '. $randomNumber. '. You guessed: '. $guessedNumber. '<br/>'; echo '<a href="index.php">Try again?</a>'; exit(); } echo '</center>'; }   [align=justify]So what have we done here? We checked to see if the field was a number and if not give and error and send back then we check if the field was empty and give them error if it was. Then we create a variable to hold our users input, we do our normal security function, however this time we +0 to because 200+0 is 200. So if it's anything else but a number it will equal zero. Next we use the rand(); function to generate a random number, the first parameter is our minimum number, the second parameter is the maximum number it will generate. We put it in a variable so we can call it easily without having to much trouble. Next we run a simple if-else statement comparing the user input variable with the random number variable to check if they are the same, it will give them the success message otherwise it will give them the error message. Some operators I have used || - this operator means or, so we check if the variable is set OR empty. === - used to compare two things against each other. ! - checks if it's the opposite (sort of like that) so the function isset() is used to check if a variable IS set however by putting "!" we are checking if it's not set. This concludes my tutorial! Mess around with that stuff to make some thing, tell me if you like this, and where I can improve! If you did find this informative then please share. If you want to get in touch with me you could message me on here. If you want me to PasteBin the code to make it more clear, then do ask and I shall do it. If you would like to see more of these tutorials don't hesitate to ask on this article by replying or any other means you have. [/align]
  17. Change the LIMIT 1 to LIMIT HowManyYouWant. MTG please clarify if this is correct as I don't know if this is the right table.   if(!$v2) { if(!$mysqli) { $q = mysql_query("SELECT * FROM `newscontent` LIMIT 1", $c) or exit(mysql_error()); $ncontent = mysql_num_rows($q) ? mysql_result($q, 0, 0) : 'No news available'; $q = mysql_query("SELECT * FROM `papercontent` LIMIT 1", $c) or exit(mysql_error()); $content = mysql_num_rows($q) ? mysql_result($q, 0, 0) : 'No news available'; } else { $q = mysqli_query($c, "SELECT * FROM `newscontent` LIMIT 1") or exit(mysqli_error($c)); $ncontent = mysqli_num_rows($q) ? mysqli_result($q) : 'No news available'; $q = mysqli_query($c, "SELECT * FROM `papercontent` LIMIT 1") or exit(mysqli_error($c)); $content = mysqli_num_rows($q) ? mysqli_result($q) : 'No news available'; } } else { $q = $db->query("SELECT * FROM `newscontent` LIMIT 1"); $ncontent = $db->num_rows($q) ? $db->fetch_single($q) : 'No news available'; $q = $db->query("SELECT * FROM `papercontent` LIMIT 1"); $content = $db->num_rows($q) ? $db->fetch_single($q) : 'No news available'; }
  18. From where you started, you've come a long way, I have to say, I can see this being a popular theme. Great job. :)
  19. You did it! Great job pal. :) How did you do it? :confused:
  20. I don't think there actually was a V1, but the last one there seems to be was a 0.85, however here is the site GL Site have look around and see if you can find anything.
  21. I tried that, however when I then put a number like 1.2, it will automatically change to 1, any ideas why?
  22. You go in to your site admin panel then you click on import module, find that module file then import, it will do the rest. NWE as you might see has an uncommon file extension, that is because the only thing this type of file works on is the NWE engine. It was made specifically for it.
  23. How do you store numbers with points in a PMA table. So what data type do I use? I figured out how to do it, you have to use double. For some reason decimal didn't work (which I thought it would be because of the name). If anyone knows why it didn't work, please post as it would clear up and will help me and other too.
  24. Script47

    Modular Layout

    If anyone is interested in how I did it then I will gladly put it on here. Just give me a shout.
  25. Script47

    Modular Layout

    Yeah I have done, on mine that was something I just thought to make sure I was doing right, thanks Kyle. :)
×
×
  • Create New...