PDA

View Full Version : Tutorial :: Making a DJ Says



dani342us
19-03-2006, 11:50 PM
This is actually very simple to do. All you have to know is a bit of MySQL and PHP and thats all. Anyways, lets start. First, make a Database then add this table to it


CREATE TABLE `djsays` (
`message` varchar(250) NOT NULL default 'No Message',
PRIMARY KEY (`id`)
) TYPE=MyISAM;

Next we will need to connect to that database and that user. Use this.


<?
ob_start(); // allows you to use cookies
$conn = mysql_connect("localhost","DATABASE USERNAME","DATABASE PASSWORD");
mysql_select_db(DATABASE NAME) or die(mysql_error());
//fill in the above lines where there are capital letters.
$logged = MYSQL_QUERY("SELECT * from users WHERE id='$_COOKIE[id]' AND password = '$_COOKIE[pass]'");
$logged = mysql_fetch_array($logged);
//the above lines get the user's information from the database.
?>

Save that as config.php

Next we will need the page for the DJ to send the message. This part is simple. Here we go.


<?
ob_start();
include("config.php");
<form method=\"POST\">
<tr>
<td align=\"right\" width=\"25%\">
Location
</td>
<td align=\"left\">
<input type=\"text\" size=\"25\" maxlength=\"25\" name=\"djsays\" value=\"$djsays[djsays]\"></td>
</tr>
<td align=\"left\">
<input type=\"submit\" name=\"update\" value=\"Update\"></td>
</tr>
</table>
</form>
</center>");
}
else
{
$djsays = htmlspecialchars($_POST[djsays]);
// the above lines get rid of all html.
echo ("Your profile has been updated!");
$update = mysql_query("Update users set djsays = '$djsays'
// updates the information in the database.
?>

Okay, save that as djsaysform.php

Easy yes?

Next we need to make a page that will say the message, thats very simple aswell, trust me.

Just make a page called djmessage.php and in it put


<?php
ob_start();
include("config.php");
echo ("DJ Says: $djsays[djsays]<br />
");
?>

Now if you want this to appear somewhere withouth having to have it as an iframe just put

<?
include("djmessage.php");
?>
where ever you want it be.

By the way this is my first tutorial ever. Hopefully you all like it and it works.

Oh, by the way I really dont know if this works I just wrote it from the top of my head. Just test it to see.

timROGERS
20-03-2006, 03:20 PM
The users table appears by magic? :S

lMattz
20-03-2006, 04:04 PM
Mmm, ill have to try that later.

Recursion
20-03-2006, 04:06 PM
This looks familiar to the techtuts one. The techtuts one has alot of errors in it.

ADAM:
20-03-2006, 04:22 PM
i swear i have seen this one before :S

Tomm
20-03-2006, 04:38 PM
Lol it dont even work :P

Php
20-03-2006, 04:41 PM
Lol it dont even work :P

I agree, It Dont Work :S

nets
20-03-2006, 04:45 PM
I'll run it on my test server to see if I can get it working.

Edit: The SQL isn't correct, so I haven't even tested the rest.

RYANNNNN
20-03-2006, 08:12 PM
Well where the **** does the dj login? You dont need a users table.

TooShort4
20-03-2006, 08:19 PM
This tutorial has been stolen from TechTuts.com

ADAM:
20-03-2006, 09:17 PM
I just wrote it from the top of my head.


If he got it from techtuts why is he getting credit for something he didnt even make :| Even if it didnt work you shouldnt take credit from something you didnt make.

Robbie..
20-03-2006, 09:18 PM
And it's basically a load of... poo.

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