Hai there.. Before I continue my problems, I would like to apologize for my poor English. I am beginners in php programming.
What I want to do are :
- I want to create a error handler function or objects in php 5. The development concept are all the items inside the dialog box that display Feedback Title, Feedback Messages, Icon and Action Button are variables that will save inside the tables.
- I can call that function by enter the Feedback Title, Feedback Messages, Icon and Action Button parameters.
Please help me, I need guide. Thanks
Newbie Need Help in Function For PHP 5
Moderator: General Moderators
- thomas777neo
- Forum Contributor
- Posts: 214
- Joined: Mon Mar 10, 2003 6:12 am
- Location: Johannesburg,South Africa
Ok, here is a simple example to work with...
I haven't put any error checking.
sql:
feedback.php
insertFeedback.php
class.feedback.php
1. run the sql
2. create the 3 pages
3. copy into folder accessible by webserver
4. open feedback.php in browser.
5. A simple example of an object created in php.
6. First learn the basics, then move on to exception handling etc
I haven't put any error checking.
sql:
Code: Select all
drop table if exists feedback;
create table feedback
(
id int(10) auto_increment primary key,
title varchar(150),
message text,
icon varchar(150),
action varchar(150)
);Code: Select all
<p>Feedback</p>
<form name="form1" method="post" action="insertFeedback.php">
<table>
<tr>
<td>Title</td>
<td><input name="title" type="text" id="title"></td>
</tr>
<tr>
<td>Message</td>
<td><textarea name="message" cols="30" rows="5" id="message"></textarea></td>
</tr>
<tr>
<td>Icon</td>
<td><input name="icon" type="text" id="icon"></td>
</tr>
<tr>
<td>Action</td>
<td><input name="action" type="text" id="action"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form>Code: Select all
require_once("class.feedback.php");
$feedback = new feedback; // created new object
$feedback-> insert_feedback($title,$message,$icon,$action);Code: Select all
class feedback
{
function insert_feedback($title,$message,$icon,$action)
{
$connection = mysql_connect("host","username","password");
mysql_select_db("misc");
$sql = "INSERT INTO feedback(title,message,icon,action) VALUES ('$title','$message','$icon','$action')";
mysql_query($sql);
}
}2. create the 3 pages
3. copy into folder accessible by webserver
4. open feedback.php in browser.
5. A simple example of an object created in php.
6. First learn the basics, then move on to exception handling etc