WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
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 Index
Web Development Resources
Web Development Content
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
Forex Trading Online forex trading platform

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 1 times)
Viewed : 2334
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 
 

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
phpFormGenerator for Dynamic Form Generation from MySQL
Categories : PHP, PHP Classes, MySQL, Databases, HTML and PHP
Zip code range and distance calculation class v1.0.0
Categories : PHP, Databases, MySQL, Zip Code



How to load a query result into a PHP Array
Categories : PHP, Databases, Arrays, MySQL
Functions for loading images into a MySQL database and displaying them.
Categories : Graphics, HTML and PHP, MySQL, PHP, Databases
for each record, do this to the first record, and do that to any subsequent record
Categories : PHP, Databases, MySQL, Beginner Guides
PHP4 AND MySQL Authentication
Categories : PHP, MySQL, Authentication, Databases
Displaying records of database in more than one page (paging)
Categories : Databases, MySQL, PHP
A Complete table(ADD,EDIT,VIEW,DELETE) management System PHP,MYSQL, JAVASCRIPT
Categories : PHP, MySQL, Java Script, Databases
This is Yet Another Sql Abstraction Library. Include it in your script and you can use the most important SQL functions without worrying about the SQL backend.
Categories : Databases, PHP, ODBC, MySQL, PostgreSQL
Create and restore backup of MySQL databases
Categories : MySQL, Databases, PHP, PHP Classes, Complete Programs
Caldera Openlinux 1.2 Standard
Categories : Web Servers, MySQL, PHP, Apache, Databases
simple script to send emails via a html-form to different users
Categories : Email, MySQL, PHP, Databases
A Simple Script that stores encrypted messages in databases
Categories : PHP, Databases, MySQL, Security