PHP OOP form info to database and e-mail system

Keeping on the same page while loading different includes based on for

Page 1 of 1

5 Replies - 6525 Views - Last Post: 30 May 2007 - 03:17 PM Rate Topic: -----

#1 supersssweety  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 22
  • View blog
  • Posts: 373
  • Joined: 16-March 07

PHP OOP form info to database and e-mail system

Posted 29 May 2007 - 07:58 AM

Hi, my name is Kacie and I work for a small web design company. I am going to school for software engineering. I know a little PHP and I have studied and understand high level OOP. I have not been able to get my hands really dirty yet in either one. We have some dead time and what I am doing is just for play and practice. We have this site setup

http://www.executive...com/newyork.cfm

It is in cold fusion and it works just fine and we won't be changing it, I just want to see if I can do this. This system was not written by programmers and I think it could be more effciently done in OOP PHP. I am not sure though how I would approach it. Again I am not experienced much at all in PHP or any real language for that matter, I can read code and understand it and even work with it, but to do this I was wondering if there was anything I might need to know about PHP specific. Like will I need sessions or cookies? Attached is a diagram (not in any standard form just something I came up w/ so I could visually understand the system) that I made.

what I want to know is can this be done with OOP, would it be more efficent, and how would I approach it in PHP, the goal is to never leave newyork.cfm (or .php once I convert it)

I also can't really see the classes I would make, in school we worked with a chat program, that is a lot different than this. So some class suggestions would help too.

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: PHP OOP form info to database and e-mail system

#2 Styx  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 192
  • Joined: 04-March 07

Re: PHP OOP form info to database and e-mail system

Posted 29 May 2007 - 12:50 PM

First, full OOP support for PHP was included in the PHP 5 release, so you'll be working with that unless you want watered-down OOP (PHP 4).

Then, to achieve your goal, and to know what you need, it depends on what you are doing. If you want to go to other parts of the site and still be associated with, say, newyork, then you might need sessions or cookies. And then, knowing which you'll need depends on what you want to accomplish. Cookies are usually fine for most things that don't need extensive authentication, while sessions are used for member systems and shopping carts. If all you are doing is submitting a form and that's it, you wont need either, and can easily accomplish this with just html (the action attribute of form).

For your objects, the best thing might be to make a class defining the various components of your form so you can easily create a new object for each of your cities. And you might consider using a class for database access.

Hope that helps! ^_^
Was This Post Helpful? 0
  • +
  • -

#3 supersssweety  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 22
  • View blog
  • Posts: 373
  • Joined: 16-March 07

Re: PHP OOP form info to database and e-mail system

Posted 29 May 2007 - 01:02 PM

View PostStyx, on 29 May, 2007 - 12:50 PM, said:

First, full OOP support for PHP was included in the PHP 5 release, so you'll be working with that unless you want watered-down OOP (PHP 4).


Would you say OOP is just not worth doing in PHP 4? Is it that bad?
Was This Post Helpful? 0
  • +
  • -

#4 Styx  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 192
  • Joined: 04-March 07

Re: PHP OOP form info to database and e-mail system

Posted 29 May 2007 - 04:08 PM

In PHP 4, OOP support is poor, but still functional for basic things. To create a variable, use the var keyword or function to create a function with no support for access level modifiers or class/instance variables. There are constructors and some inheritance through extends, but no interfaces, abstract classes, method overloading, or exceptions.

But if you don't really need all those things, then PHP4 is just fine. A little example:
<?php
class Example
{
  var $test = '';

  function Example($test)
  {
	$this->test = $test;
  }

  function display_test($test)
  {
	echo $test;
  }
}

$test = new Example('testing');
$test->display_test($test->test);
?>


OOP in PHP4
OOP in PHP5
Was This Post Helpful? 0
  • +
  • -

#5 supersssweety  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 22
  • View blog
  • Posts: 373
  • Joined: 16-March 07

Re: PHP OOP form info to database and e-mail system

Posted 30 May 2007 - 09:27 AM

I see, well I don't know if I would need any of that or not. If I ever get started on it, I will let you know how it goes. I will probably need syntax help ;)
Was This Post Helpful? 0
  • +
  • -

#6 Styx  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 192
  • Joined: 04-March 07

Re: PHP OOP form info to database and e-mail system

Posted 30 May 2007 - 03:17 PM

ok then, good luck! ^_^
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1