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
Mobile Dev World

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 : 3136
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
Cut your MySQL Connections to 1 line of code
Categories : PHP, Beginner Guides, Databases, MySQL
Multi-table database search for your WAP-enabled device. Uses PHP and MySQL. No WMLscript.
Categories : WAP, WML, PHP, MySQL
A template script to provide the ability to get the next or previous n records from a MySQL database.
Categories : Databases, PHP, MySQL
BBS system for easy customization. Utilizes mySQL.
Categories : Complete Programs, MySQL, PHP, Databases
Broadcast HTML Email
Categories : PHP, Email, MySQL, Databases
Security, Password lock out after three tries, authorization fails and is logged locked out of account till admin decides he will unlock it.
Categories : Sessions, PHP, MySQL, PHP Options and Info
Returns the last row from a select where multiple rows have been selected. In this case it is used to determine the last number in an AUTO_INCREMENT column. I use it to create "ticket numbers" or anything that needs a unique ID in sequence.
Categories : mSQL, MySQL, Databases, PHP
MySQL Connection/Query Class
Categories : Databases, MySQL, PHP, PHP Classes
MySQL to XML.
Categories : MySQL, XML, PHP
Complex paging with no resultset limit
Categories : PHP, MySQL, Databases, Output Control, HTML and PHP
Phorum, MySQL, Language, UK date format, MySQL UK Date format
Categories : PHP, Date Time, Strings, MySQL, Databases
PHP Calendar Web App
Categories : PHP, Databases, MySQL, Date Time, Calendar
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