WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Net Send Messaging with PHP
Categories : PHP, MySQL Click here to Update Your Picture
Wayne Kraper
Date : Sep 25th 2008
Grade : 1 of 5 (graded 2 times)
Viewed : 4959
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Wayne Kraper
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

I set up a web based interface that our office users can utilize to send instant messages via the Windows Net Send command.
The users names are pulled from a MySQL database. I also used an old javascript I pull from the internet years ago to put
the messaging screen in a pop-up format. It uses 4 files to complete the task although the second and third pages could be
combined. The 4th file is the batch file built on the third page.

/* Put this link on your main page or wherever you want to place the link*/
<A HREF="" onClick="window.open('file1.php', 'indexWnd', 'width=370,height=240,status=1'); return false;"> Instant Messaging</A>




//Save this as file1.php or again whatever you choose to call it
<BODY bgcolor="#99ccff" text="#000000" vlink="#FFD700" link="#800000">
<?php
//I use an inc file to hold the database connection info
include("connect1.inc");
@
MYSQL_SELECT_DB($dbname) or die ("Unable to select database");
$sql="SELECT * FROM table order by usr desc";
/* usr is the field name in the database that contains the message receiptants name the table also holds the computer host name */
$result=mysql_query($sql);
$num=mysql_numrows($result);
$row = mysql_fetch_array($result);
mysql_close();
$i=0;

   echo
"<table><td><tr><b>Instant Messaging System</b><br></td>" ;
echo
"<form method=\"POST\" action=\"file2.php\">";
echo
"<select name=\"sfield\" size=\"1\">";
echo   
"<option selected value=\"Make Selection\">Make Selection</option>";

while (
$i < $num) {
$var2=mysql_result($result,$i, "usr");
echo   
"<option value=\"$var2\">$var2</option>";

     
$i ++;
}
echo
"</select>";
?>
</select></p>
<p><input type="text" name="message" align="LEFT" value="" size="50"></p></input>
<p> </p>
  <p><input type="submit" value="Send Message"  name="B1"></p> </form>
 
</body>




// This is the final file or file2.php
<?php
$var1
=$_POST['message'];
$sfield=$_POST['sfield'];

include(
"connect1.inc"); // again I use an inc file to house the database connection info
@MYSQL_SELECT_DB($dbname) or die ("Unable to select database");
$sql="SELECT * FROM tablewhere usr like '%$sfield%' ";
$result=mysql_query($sql);
$num=mysql_numrows($result);
$row = mysql_fetch_array($result);
$i=0;
mysql_close();


while (
$i < $num) {
$host=mysql_result($result,$i, 'computer_name');
$sfield=mysql_result($result,$i, 'usr');
     
$i ++;
}

echo
"Message sent to $sfield<br>";

if(
is_file("send.bat")) {
unlink("send.bat")  or die ("Could not delete file.");
}

$myFile = "send.bat";
$fh = fopen($myFile, 'a+') or die("can't open file");
$stringData = "net send ";
fwrite($fh, $stringData);
$stringData = "$host ";
fwrite($fh, $stringData);
$stringData = "$var1 ";
fwrite($fh, $stringData);
fclose($fh);
exec("send.bat",$output);

//loop back to the original page
include("test.php");
?>



bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager
Categories : MySQL, PHP, MySQL, Complete Programs, Databases
Link Manager for Link Exchangers
Categories : PHP, PHP Classes, Databases, MySQL, CURL
Web Self Service Resource Scheduler Using php3 and MySQL
Categories : PHP, Complete Programs, MySQL
Record Set Paging with PHP (RSP)
Categories : PHP, MySQL, Navigation, Databases, HTML and PHP
Sort the results from a SELECT query (any number of columns) into an array automatically.
Categories : PHP, PHP Classes, Arrays, Databases, MySQL
usercounter class
Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables
This PHP function creates dropdown select lists for time and date that you can change, outputs a 14 char MySQL timestamp in a text field
Categories : PHP, MySQL, Java Script, HTML and PHP
Implementing a Members ONLY area
Categories : PHP, MySQL, Databases, Authentication
PHP3 Authentication using MySQL (also has nice query_db() function to return an array of arrays from a MySQL query result).
Categories : Authentication, MySQL, PHP
Browse a MySQL database & draw a tree view & load final items into a template page.
Categories : MySQL, Complete Programs, Algorithms, PHP, Databases
Inserting data to a MySQL Database using AJAX
Categories : AJAX, HTTP, PHP, Databases, MySQL
AJAX Application
Categories : PHP, AJAX, Databases, MySQL
Convert MYSQL timestamp (14) fields back to UNIX epoch (seconds) format for display with the date() function. "revertTimeStamp($timestamp)"
Categories : PHP, Date Time, MySQL
Simple pipe delimited file export program that downloads to a local machine
Categories : PHP, Filesystem, Databases, MySQL, HTTP
How to thread a list of messages in database and show it in a treelike structure
Categories : PHP, MySQL, Databases