I keep getting this error. And I don't know why... Thanks
Notice: Undefined index: UserID in C:\wamp\www\tweetball\classes\word.class.php on line 35
<?php
session_start();
class Word
{
private $m_sWord;
private $m_sMessage;
private $link;
public function __set($p_sProperty, $p_vValue)
{
switch($p_sProperty)
{
case "Message":
$this->m_sMessage = $p_vValue;
break;
}
}
public function __get($p_sProperty)
{
$vResult = null;
switch($p_sProperty)
{
case "Message":
$vResult = $this->m_sMessage;
break;
}
return $vResult;
}
public function Save()
{
include("Connection.php");
$sSql = "insert INTO words (word, FK_UserID) VALUES ('$_POST[message]','$_POST[UserID]')";
if ($rResult = mysqli_query($this->link, $sSql))
{
echo "";
}
else
{
throw new Exception('We could not save your word!');
}
mysqli_close($this->link);
}
public function CreateNew()
{
$m_sHost = "localhost";
$m_sUser = "root";
$m_sPassword = "";
$m_sDatabase = "tweetball";
$link = mysqli_connect($m_sHost,$m_sUser,$m_sPassword,$m_sDatabase);
if($link!=null){
$this->link=$link;
}
else
{
throw new Exception("There seems to be a database problem. Try again later");
}
}
public function getWord()
{
$m_sHost = "localhost";
$m_sUser = "root";
$m_sPassword = "";
$m_sDatabase = "tweetball";
$sSql = "select * from tweetball where WordID = 1;";
if ($rResult = mysqli_query($this->link, $sSql))
{
$singleRecord = mysqli_fetch_assoc($rResult);
$message = $singleRecord['Word'];
}
else
{
throw new Exception('We could get your word!');
}
mysqli_close($link);
return($message);
}
}
?>