add user.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns=""><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>

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

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

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

my class.php

    function add_user() {

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

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

                echo "<p>The username is required!</p>";
                echo "<p>The password is required!</p>";

            echo '<p><a href="add_content.php">Try again!</a></p>';
            $sql = "INSERT INTO users VALUES(null,'$username','$password')";
            $res = mysql_query($sql) or die(mysql_error()); 
            echo "added Successfuly";
    }//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????

Recommended Answers

All 3 Replies

What is this:


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, learning, and sharing knowledge.