PDA

View Full Version : TechTuts Usersystem



Evasion
03-06-2006, 09:31 AM
Since TectTuts are down I can't view any of there tutorials.
Does anyone have a working messages.php with a text box instead of a drop down box?

Rep to anyone who can help :).

jshost
04-06-2006, 12:48 AM
Im pretty sure that all you would have to do is insert a text box but name it the same as the drop down box and it would work

Recursion
04-06-2006, 07:53 AM
anybody actually have the usersystem ready to download because TechTuts is still down >=[

Evasion
04-06-2006, 08:13 AM
I know how to add the text box I basicly need the whole members.php page. It was just handy if someone had the text box with it.

jshost
04-06-2006, 01:40 PM
i would post mine but ive alterd it quite a bit as its got 5 badges and a few other things

ClubTime
04-06-2006, 01:50 PM
i think i have it, i want the queries for the whole system if anybody has =]

ClubTime
04-06-2006, 01:51 PM
<?
ob_start();
//the above line needs to be above ALL HTML and PHP (except for <?).
include("config.php");
//gets the config page, which connects to the database and gets the user's information
if ($logged[username])
{
//checks to see if they are logged in
switch($_GET[page])
{
//this allows us to use one page for the entire thing
default:
echo ("- <a href=\"messages.php?page=inbox\">Inbox</a><br />
- <a href=\"messages.php?page=write\">New Message</a>");
break;
case 'write':
if (!$_POST[send])
{
//the form hasnt been submitted yet....
echo ("<form method=\"POST\" style=\"margin: 0px;\">
<dl style=\"margin: 0px;\">
<dt>recipient</dt>
<dd>
<select name=\"to\">
");
$getusers = mysql_query("SELECT * FROM users ORDER BY 'username' ASC");
while ($users = MySQL_Fetch_Array($getusers)) {
echo ("<option value=\"$users[username]\">$users[username]</option>");
}
//the above line gets all the members names and puts them in a drop down box
echo ("
</select>
</dd>
<dt>Message Subject</dt>
<dd><input type=\"text\" name=\"subject\" size=\"20\"></dd>
<dt>Message</dt>
<dd><textarea rows=\"7\" name=\"message\" cols=\"35\"></textarea>
</dd><dt> </dt>
<dd><input type=\"submit\" value=\"Submit\" name=\"send\"></dd>
</dl>
</form>
");
}
if ($_POST[to])
{
//the form has been submitted. Now we have to make it secure and insert it into the database
$subject = htmlspecialchars(addslashes("$_POST[subject]"));
$message = htmlspecialchars(addslashes("$_POST[message]"));
$to = htmlspecialchars(addslashes("$_POST[to]"));
//the above lines remove html and add \ before all "
$send = mysql_query("INSERT INTO `pmessages` ( `title` , `message` ,
`touser` , `from` , `unread` ,
`date` ) VALUES ('$subject', '$message', '$to',
'$logged[username]', 'unread', NOW())");
echo ("Your message has been sent.");
}
break;
case 'delete':
if (!$_GET[msgid])
{
echo ("Sorry, but this is an invalid message!");
}
else
{
$getmsg = mysql_query("SELECT * from pmessages where id = '$_GET[msgid]'");
$msg = mysql_fetch_array($getmsg);
//hmm..someones trying to delete someone elses messages! This keeps them from doing it
if ($msg[touser] != $logged[username])
{
echo ("This message was not sent to you!");
}
else
{
$delete = mysql_query("delete from pmessages where id = '$_GET[msgid]'");
echo ("Message Deleted");
}
}
break;
case 'inbox':
$get = mysql_query("SELECT * from pmessages where touser = '$logged[username]' order by id desc");
echo("
<table bgcolor=\"#dddddd\" border=\"0\" width=\"100%\" cellspacing=\"0\">
<tr>
<td align=\"center\">Subject</td>
<td align=\"center\" width=\"125\">From</td>
<td align=\"center\" width=\"97\">Date</td>
<td width=\"25\">Delete</td>
</tr>
</table>
");
$nummessages = mysql_num_rows($get);
if ($nummessages == 0)
{
echo ("You have 0 messages!");
}
else
{
echo("<table border=\"0\" width=\"100%\" cellspacing=\"1\">");
while ($messages = mysql_fetch_array($get))
{
//the above lines gets all the messages sent to you, and displays them with the newest ones on top
echo ("
<tr>
<td><a href=\"messages.php?page=view&msgid=$messages[id]\">");
if ($messages[reply] == yes)
{
echo ("Reply to: ");
}
echo ("$messages[title]</a></td>
<td width=\"125\">$messages[from]</td>
<td width=\"97\">$messages[date]</td>
<td width=\"25\"><a href=\"messages.php?page=delete&msgid=$messages[id]\">Delete</a></td>
</tr>");
}
echo ("</table>");
}
break;
case 'view':
//the url now should look like ?page=view&msgid=#
if (!$_GET[msgid])
{
//there isnt a &msgid=# in the url
echo ("Invalid message!");
}
else
{
//the url is fine..so we continue...
$getmsg= mysql_query("SELECT * from pmessages where id = '$_GET[msgid]'");
$msg = mysql_fetch_array($getmsg);
//the above lines get the message, and put the details into an array.
if ($msg[touser] == $logged[username])
{
//makes sure that this message was sent to the logged in member
if (!$_POST[message])
{
//the form has not been submitted, so we display the message and the form
$markread = mysql_query("Update pmessages set unread = 'read' where id = '$_GET[msgid]'");
//this line marks the message as read.
$msg[message] = nl2br(stripslashes("$msg[message]"));
//removes slashes and converts new lines into line breaks.
echo ("
<form method=\"POST\" style=\"margin: 0px;\">
<dl style=\"margin: 0px;\">
<dt><b>$msg[title] -- From $msg[from]</b></dt>
<dd>$msg[message]</dd>
<dt><b>Reply</b></dt>
<dd><textarea rows=\"6\" name=\"message\" cols=\"45\"></textarea></dd>
<dt> </dt>
<dd><input type=\"submit\" value=\"Submit\" name=\"send\"></dd>
</dl></form>");
}
if ($_POST[message])
{
//the form HAS been submitted, now we insert it into the database
$message = htmlspecialchars(addslashes("$_POST[message]"));
$do = mysql_query("INSERT INTO `pmessages` ( `title` , `message` , `touser` , `from` , `unread` ,
`date`, `reply`) VALUES
('$msg[title]', '$message', '$msg[from]', '$logged[username]',
'unread', NOW(), 'yes')");
echo ("Your message has been sent");
}
}
else
{
//hmm..this message was NOT sent to the logged in user...so we won't display it.
echo("<b>Error</b><br />");
echo ("This message was not sent to you!");
}}
break;
}
echo("<br /><br /><div align=\"center\"><b><a href=\"?page=inbox\">Inbox</a> · <a href=\"?page=write\">New Message</a></b>");
}
?>
<body bgcolor="#800000">

Enjoy you just might want to change the background color i think thats all i edited

MattUH
04-06-2006, 01:52 PM
Sygon has the full system {basic}.

ClubTime
04-06-2006, 02:11 PM
Thanks i'll ask him

Rob
04-06-2006, 07:03 PM
I have it. I'll ZIP the tutorial and upload it.

Rob

EDIT: Here http://www.uploadz.co.uk/share.php?zip=208158techtuts-usersystem.zip

Kymux
06-06-2006, 08:38 PM
That better be safe. No thanks. If it's safe i'll +rep you.

Sygon.
06-06-2006, 08:43 PM
the bad thing about using a textbox is they eed to get it corect u need a function thatll do something bout htt

Rob
07-06-2006, 11:46 AM
That better be safe. No thanks. If it's safe i'll +rep you.

Yeah it's safe. I don't send people viruses, I'm not that kind of guy.

Rob

Sygon.
07-06-2006, 04:50 PM
I have it. I'll ZIP the tutorial and upload it.

Rob

EDIT: Here http://www.uploadz.co.uk/share.php?zip=208158techtuts-usersystem.zip

Lol@ tht i sent you those :)

Rob
07-06-2006, 11:03 PM
Lol@ tht i sent you those :)

You sure did Mr. Sygon :)

Want to hide these adverts? Register an account for free!