Okay so I am creating a simple blog from scratch, with mysql "phpmyadmin" godaddy supplies it, php in dreamweaver, and css and html in dreamweaver also. Just for practice, no real reason. I have a new_user.php file that I can't fix to use my objects. I know how to create a class and its properties, an object essentially.., and instantiate it. But I don't know how to do this in the real world and actually use it for two objects, BlogUser and BlogEntry, I don't even have the blog on the website yet but i do have it to where I cant create new staff users to use the cms i built to edit the website. It's such a simple problem but I don't see any help on it anywhere. I have a bunch more files that connect to this but I cant attach them and it would be impossible to read if i just pasted them all here.
new_user.php
<?php require_once("includes/session.php"); ?>
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php confirm_logged_in(); ?>
<?php
include_once("includes/form_functions.php");
// START FORM PROCESSING
if (isset($_POST['submit'])) { // Form has been submitted.
$errors = array();
// perform validations on the form data
$required_fields = array('username', 'password');
$errors = array_merge($errors, check_required_fields($required_fields, $_POST));
$fields_with_lengths = array('username' => 30, 'password' => 30);
$errors = array_merge($errors, check_max_field_lengths($fields_with_lengths, $_POST));
$username = trim(mysql_prep($_POST['username']));
$password = trim(mysql_prep($_POST['password']));
$hashed_password = sha1($password);
if ( empty($errors) ) {
$query = "INSERT INTO users (
username, hashed_password
) VALUES (
'{$username}', '{$hashed_password}'
)";
$result = mysql_query($query, $connection);
if ($result) {
$message = "The user was successfully created.";
} else {
$message = "The user could not be created.";
$message .= "<br />" . mysql_error();
}
} else {
if (count($errors) == 1) {
$message = "There was 1 error in the form.";
} else {
$message = "There were " . count($errors) . " errors in the form.";
}
}
} else { // Form has not been submitted.
$username = "";
$password = "";
}
?>
<?php include("includes/header.php"); ?>
<table id="structure">
<tr>
<td id="navigation">
<a href="staff.php">Return to Menu</a><br />
<br />
</td>
<td id="page">
<h2>Create New User</h2>
<?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?>
<?php if (!empty($errors)) { display_errors($errors); } ?>
<form action="new_user.php" method="post">
<table>
<tr>
<td>Username:</td>
<td><input type="text" name="username" maxlength="30" value="<?php echo htmlentities($username); ?>" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" maxlength="30" value="<?php echo htmlentities($password); ?>" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Create user" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<?php include("includes/footer.php"); ?>
and this is what I think my include.inc file will look like
class BlogUser {
protected $User_name;
protected $User_email;
protected $User_password;
protected $User_signup_date;
}
class BlogEntry {
public $Blog_title;
public $Blog_category;
protected $Blog_body;
protected $Blog_draft_date;
protected $Blog_modify_date;
}
But I don't know where I'm supposed to declare their behaviors or properties. in the same file I assume?
any help on the matter would be greatly appreciated. oop with php is a nightmare if you are a noob who solely learned php and sql without the oo portion.



