473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How do I do an insert to mysql on the onsubmit using object oriented coding?

I am trying to use more object oriented code with PHP. I am trying to add a record to a table with the submit button, but I do I do it? I need some direction. This is not working. Thanks!

Expand|Select|Wrap|Line Numbers
  1. <form id="CMSAdd" name="CMSAdd" onsubmit="<? php $addCMSRecord = new GetCMSRecord();$addCMSRecord -> save_AddRecord(); ?>" method= $_REQUEST > 
  2.  
  3.  
  4. if (document.CMSAdd.R1.value == "ENewsletter" ) {
  5.   /*** sql to INSERT a new record ***/
  6.    $sql = "INSERT INTO enewsletter (enews_year,   enews_month, enews_title, enews_path, enews_edition)
  7.     VALUES ( CMSAdd.txtEYear.value, CMSAdd.optEMonth.value, CMSAdd.txtETitle.value, CMSAdd.txtELink.value, CMSAdd.optEEdition.value) or die('Couldn't insert data from eNewsletter table: '.mysql_error())";
  8.  
  9.    return $sql;
  10. }
Oct 7 '10 #1
2 1750
Markus
6,050 Expert 4TB
That is not valid PHP code. I don't understand the problem, either.
Oct 7 '10 #2
dlite922
1,584 Expert 1GB
Start off by separating your HTML from you PHP code. Use a templating system like Smarty.

Then create classes for each of your uses. For example it would be useful for you to create a class that handles database interactions. This class would be used for everywhere in your program you need to access the DB.

Further more you could have classes for each of your objects. If you're program deals with students, you could have a students class that stores student information.

But most importantly of all, OOP and PHP have nothing to do with HTML. HTML cannot be OOP because it's not a programming language, it's a markup language. HTML = HyperText Markup Language"

Cheers Mate,


Dan
Oct 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

54
by: Jerry | last post by:
What are the advantages and disadvantages of using Object Oriented PHP vs Java?
4
by: mihai | last post by:
I wander what is the penalty of speend for using object oriented programming (C++) against the play C. Have a nice day, Mihai
14
by: Rookie | last post by:
Is C an object oriented programming language?
1
by: indiarocks | last post by:
I have been developing a application in Python which instantiates objects on the fly. I want to adopt a Object Oriented approach in what I am developing. So far what I have been doing is Script 1...
46
by: ajba74 | last post by:
Hi fellows, I am reading some books to learn the C programming language, and sometimes I have the feeling that when somebody becomes a C expert, he must learn a more modern and object-oriented...
5
by: virtualadepts | last post by:
I have code here that explains my object oriented design model. I've been reading about other design models from what is documented on wikipedia about the key book on the subject:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.