add user.php

<?php
include '../_class/_class.php';

$obj = new modernCMS();

//Setup connection vars
$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = '';
$obj->db = 'cms';
//connect to db
$obj->connect();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DCJR :: Home</title>
</head>

<body>
<div class="wrapper">
<div class="navigation">
<h1><a href="add_content.php">add content</a></h1>
</div>
<form method="post" action="index.php">

    <input type="hidden" value="true" />
    <div>
    <label for="username">username:</label>
    <input type="text" name="username" id="username" /> 
    </div>

    <div>
    <label for="password">password:</label>
    <input type="text" name="password" id="password" /> 
    </div>
    <input type="submit" name="submit" value="Add User" />
</form>
</div>
</body>
</html>

my class.php

    function add_user() {

            $username = mysql_real_escape_string($p['username']);
            $password = mysql_real_escape_string($p['password']);

        if(!$username || !$password):

            if(!$username):
                echo "<p>The username is required!</p>";
            endif;
            if(!$password):
                echo "<p>The password is required!</p>";
            endif;

            echo '<p><a href="add_content.php">Try again!</a></p>';
        else:
            $sql = "INSERT INTO users VALUES(null,'$username','$password')";
            $res = mysql_query($sql) or die(mysql_error()); 
            echo "added Successfuly";
        endif;
    }//ends add_user

Notice: Undefined variable: p in C:\xampp\htdocs\dcjr_class\dcjr_class.php on line 78

why am i getting this notice?? anyone help please????

What is this:

$p['username']

What are you trying to do here? I think you're getting confused. Where are you defining your class variables? Show these :)

you don't appear to be passing $p to user_class(), unless it is a defined variable for your class then there is no way for the method to get that variable data.
function add_user($p)

dont know what i did but now it works after i put the

function add_user(*$p*){ 
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.