Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

gsingh85

Members
  • Joined

  • Last visited

  1. Ok so should I put the __construct function into the comment class? So I could have public function__construc() { $this ->author = ; // what would I put here? I want to maintain the code I have created without doing any major re-writes.
  2. Well I have tried to do it without using classes and objects and it works fine but I want to now re-do it using OOP. It's just for a learning excerise which is why it's simple. With regards to this code: function __construct($arg_one,$arg_two) { $this->arg_one = $someValueYouWant; $this->arg_two = $anotherValue; } where would I put this function. Is it in the comments or user class? It's done now the ways it's done so once this is complete I will adjust it for the one class. To avoid complications I will leave it as two classes for now. Anyway, where you have put arg_one, arg_two what would these be in the context of my code? Also in the Comment class the two properties have gone. Are you able to do it so we can keep these properties and have objects of the class?
  3. Yes I have included everything. That's the complete code. The reason why I have left the user class empty is because I'm not sure what to put in it. Shall I had this function into the Comment class: public function __construct
  4. Ok I've literally been at this for about 2 hours. After some tweaks I've managed to get this error: Fatal error: Call to a member function getName() on a non-object in C:\xampp\htdocs\tutorials\basiccomment\index.php on line 34 This is because of this code: $comment->author->getName() and $comment->getContent(). If I change to this: $comment->author & $comment->comment Then I don't get the above "fatal error" instead it posts empty "name" and "commentcontent". If fact it posts ":;" on the html file. I think I'm starting to understand the theory and the logic behind it but I've not got it to work so I still haven't fully grasped it. I've been switching between recommended links, sites and tutorials but they do things slightly different from each other so it's hard to fit it into a real world application. I know I've done it wrong because it's not posting anything but I'm not sure what I need to do to put it right. I've been doing some changes here and there but I've still not got it to work. I think I missing a function somewhere but I'll post the code in full if anyone is kind enough to offer me any information. <?php class Comment { public $author; public $comment; } class user { } $User = new User; $comment = new Comment($User); // now to get the author of the comment, we'd echo $comment->author; if ($_POST) { // create our data pieces $user = new User($_POST ['name']); $commentContent = $_POST ['commentcontent']; $comment = new Comment($user, $commentContent); //not quite sue what this means /** * To answer this question, this is writing the data to a file called comments.html */ $handle = fopen("comments.html","a"); fwrite($handle, "<b>" . $comment->author . "</b>:<br/>" . $comment->comment . ",<br/>"); fclose($handle); } ?> <html> <body> <form action = "" method = "POST"> Comments: <textarea rows = "10" cols = "30" name = "commentcontent"></textarea><br/> name: <input type = "text" name = "name"<br/> <input type = "submit" value = "post!"><br/> </form> <?php include "comments.html"; ?> </body> </html>
  5. Thanks for your reply. Have I created the class and objects correctly?
  6. Hi Every. Over the last few days I've been working on my very basic comment box programme. I've purposly kept it basic so I can follow it. I managed to make the programme work using a tutorial without any kind of classes or objects but now I want to create the code in oop style. I've created a class which I think is right and within that class I have created 2 variables within it. I have also created 2 objects of that class however I don't think I've done it right. Can someone please have a look at it and point out where I need to make the amendments. <?php class Comment { private $author; private $comment; } $username = new comment (); $usercomment = new comment (); //if the form has been submitted then we want to execute some code in the brackets if ($_POST) { //below we have defined are variables. $username = $_POST ['name']; $usercomment = $_POST ['commentcontent']; //not quite sue what this means $handle = fopen("comments.html","a"); fwrite($handle, "<b>" . $username . "</b>:<br/>" . $usercomment . ",<br/>"); fclose($handle); } ?> <html> <body> <form action = "" method = "POST"> Comments: <textarea rows = "10" cols = "30" name = "commentcontent"></textarea><br/> name: <input type = "text" name = "name"<br/> <input type = "submit" value = "post!"><br/> </form> <?php include "comments.html"; ?> </body> </html>
  7. @citypaul - ok thats no problem. i will to see more posts from you about this video. thanks a lot.
  8. Yes I think I will do just that. It's not that difficult to learn JQ. It seems to be a collection of effects for people to use very much like CSS.
  9.    AntonioGiansante reacted to a post in a topic: Help with PHP messages
  10.    AntonioGiansante reacted to a post in a topic: Help with PHP messages
  11. I want to use Jquery for the sake of variety just so I can show off my skills in a job interview if nothing else. How about if I use Adobe Animate? Would I be able to create jquery code on there and place the code in a html script?
  12. Yes exactly. I'll give you an example and this is just an example. I want to create a gallery for one of my websites but I don't know exactly how I want the effects/animation to be so I want to expirment.
  13. I am trying to create some animation/special effects on my website and I want to use JQUERY. The thing is I want to be able to experiment because I don't really know what I want until I play around with it. Is there a way I can create jquery animation using software? For example, if I want to design a certain layout for a fashion company I could experiment using Photoshop, get the layout, colour scheme and so on but I can't see a way of doing that with Jquery.
  14. I have to say I'm really disappointed to hear you say this. I took a lot of time to learn this code from a developer who I thought was an expert in php. As someone new to php I can’t really tell the difference between good php code and bad php code. My general rule of thumb when trying to learn php code is, is it flexible? Is it lightweight? Does it work? If the answer is yes to all 3 then I will learn it and keep it for reference and re-use it. To hear you say the code is badly written and outdated is quite disheartening. This is code for creating a newsletter and I have tested it and the answer is a “yes” to the above 3 questions. If the code is so bad would you be able to post an equivalent newsletter code that is written with OOP in mind and I will study that and compare it to the “badly” written code. I can then use your code as a reference to good practise. Thanks in advance.
  15. Any more ideas?
  16. Sorry for the late response. Yes that has worked. Thanks very much, that's a really big help.
  17. Thanks for your reply. Adding those lines doesn't work because when I load the page the boxes dissappear so I can't type anything in. Any suggestions? By the way. I don't want the messages to display on a different page I would like to keep everything on the one, same page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.