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 : This is a simple PHP3 script to send an instant msg to the webmaster (only for Windows NT). Updated version 1.01!
Categories : PHP, Java Script Update Picture
Richard Vrijhof
Date : Mar 07th 2000
Grade : Be the 1st to grade this Code Example
Viewed : 3033
File : InstaMSGv1.01.zip
Images : No Images for this code example.
Search : More code by Richard Vrijhof
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php
/***************************************************************************************************************************
****************************************************************************************************************************

InstaMSG.php3 v1.01
by R.J. Vrijhof
March 7, 2000
Platform: Windows NT

Requirements:
-Windows NT (I use Windows NT Server 4 SP 5)
-Web server (I use Apache v1.3.9)
-PHP3 (I use v3.0.14)
-The Schedule Service must be working!
-And, last but not least, Notepad.exe must be in the same directory as the environment variable WINDIR!

You can reach me at: R.J.Vrijhof@bigfoot.com

****************************************************************************************************************************

Description

This is a simple script to send an instant msg to the webmaster. It does this by producing a temporary text file, then
scheduling an AT job, which will launch a batch file, which on its turn launches Notepad that shows the text file. After
closing Notepad, the text file is automatically deleted by the batch file.
This script only works on Windows NT, but I guess with some tweaks it could also be made working on any UNIX/Linux flavor
(with cron and some text editor like Emacs, or hell, if you'd like with VI :-|).

****************************************************************************************************************************

Installation

To install, follow the following steps:

1. Unzip the file you downloaded to a temporary directory.
2. Make a directory to hold the batch file and (temporary) text files.
3. Move the batch file (showmsg.cmd) to the directory you just created.
4. Move the PHP3 file to wherever you like on your web site, as long as it is reachable from the web (of course) and you can
execute PHP3 files in that directory.
5. Edit the variables below.
6. Done!

****************************************************************************************************************************

History

1.01 March 7, 2000 Fixed small (stupid) bug.
1.0 March 7, 2000 First release.

****************************************************************************************************************************
You have to set the following variables to the right values (don't forget the double backslashes in $workdir and
$wd_short and also make sure $workdir and $wd_short end with double backslashes!):
***************************************************************************************************************************/
$self = "http://your.site.com/path/InstaMSG.php3"; # (Relative) URL of this script.
$workdir = "C:\\somewhere\\"; # The directory created for the batch and text files.
$wd_short = "C:\\SOMEWH~1\\"; # The same, but now in 8.3 format.
$delay = 5; # Number of seconds the script has to delay before Notepad is opened (if
# it doesn't work and you see AT jobs being added with an execution date
# of tomorrow, you have to increase this number).
$text = "Message from \"%s\":\r\n\r\n%s"; # Leave as-is, or change it to whatever you like, just leave two %s in
# here (the first is the e-mail address, the second the message).
/**************************************************************************************************************************
You don't have to change anything beyond this point, but feel free to experiment with whatever you like. It is completely
in the public domain.
****************************************************************************************************************************
****************************************************************************************************************************
***************************************************************************************************************************/



/**************************************************************************************************************************
This function will display the HTML form for sending the message. No error checking is done on the form, neither in
JavaScript, nor in PHP3 after posting (in fact, the mail field can be left empty).
***************************************************************************************************************************/
function displayForm() {
global $self, $mail;
?>

<form name="form1" id="form1" action="<?php echo $self;?>" method="post">
Type your e-mail address here: <input type="text" name="mail" id="mail" size="20" maxlength="35" value="<?php echo $mail;?>"><br /><br />
Type your message here:<br />

<!-- If you like to push the Send button yourself, comment the following line out and uncomment the line after that: -->
<textarea name="msg" id="msg" rows="10" cols="60" onchange="document.form1.submit();" wrap="hard"></textarea>
<!-- <textarea name="msg" id="msg" rows="10" cols="60" wrap="hard"></textarea> -->

<br /><br />
<input type="submit" value="Send!">
</form>

<?php
}
/**************************************************************************************************************************
***************************************************************************************************************************
Start of the HTML output.
***************************************************************************************************************************
**************************************************************************************************************************/


/**************************************************************************************************************************
The HTML code complies with XHTML 1.0 Transitional standard.
**************************************************************************************************************************/
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/TR/xhtml1">

<head>
<title>Send instant msg to webmaster on <?php echo getenv("SERVER_NAME");?></title>
</head>

<body>

<?php
/**************************************************************************************************************************
***************************************************************************************************************************
If the msg field is empty, then it is the first time the script is run, or no msg was typed in (and so, it starts from
scratch). If you don't like that, then you have to put some error checking code in yourself, which can display a nice error
message.
**************************************************************************************************************************/
if (empty($msg)) {
?>

<br /><center><h1>Instant MSG</h1></center><br /><br />

<?php
displayForm();

/**************************************************************************************************************************
***************************************************************************************************************************
If the msg field is not empty, do your magic!
**************************************************************************************************************************/
} else {
/**************************************************************************************************************************
Strip possible slashes added by posting:
**************************************************************************************************************************/
$mail = stripslashes($mail);
$msg = stripslashes($msg);
?>

<br /><center><h1>Message sent!</h1></center><br /><br />

<?php
displayForm();
$now = time();
/**************************************************************************************************************************
Make the temporary text file:
**************************************************************************************************************************/
$fp = fopen("$workdir$now.txt", "w");
fwrite($fp, sprintf($text, $mail, $msg));
fclose($fp);
/**************************************************************************************************************************
Schedule the AT job at $delay of seconds (default: 5) from now:
**************************************************************************************************************************/
$hr = date("G", $now + $delay);
$min = date("i", $now + $delay);
$sec = date("s", $now + $delay);
exec("at $hr:$min:$sec cmd /c \"" . $workdir . "showmsg.cmd\" $wd_short$now.txt");
}
/**************************************************************************************************************************
Just for convenience:
**************************************************************************************************************************/
if (empty($mail)) {
?>

<script language="JavaScript">
// <!--
document.form1.mail.focus();
// -->
</script>

<?php
} else {
?>

<script language="JavaScript">
// <!--
document.form1.msg.focus();
// -->
</script>

<?php
}
?>

</body>

</html>



Alert in JavaScript and Trace in Flash Action script are two commands that I find very much useful for tracking and debugging errors in my scripts. Unfortunately, there is no such option in PHP.
Categories : PHP, Java Script, Debugging
Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page.
Categories : PHP, AJAX, HTML and PHP, Java Script
Linked comboboxes with php-mysql & javascript
Categories : PHP, Java Script, Databases, MySQL
PHP3 generated gif / javascript mouseover.
Categories : PHP, Java Script, MySQL
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
A simple configuration file editor to ease you life in setting up php applications. Reads variables from a given file automatically and displays current value. New value will be written to file after submit.
Categories : PHP, Filesystem, Regexps, Java Script
Popup window creator for images on the Fly.
Categories : PHP, GD image library, Java Script
PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions
Local-to-user date and time display regardless of time zone or where the website's server is located
Categories : PHP, Date Time, HTML and PHP, Java Script
day and week grid with clickable fields on/off and possibility to insert in DB
Categories : PHP, Java Script, CSS
Dynamic Calendar in PHP, Javascript and HTML.
Categories : PHP, Java Script, HTML and PHP, Calendar
Date Validation using JavaScript. Intended to use it as checkdate() from PHP.
Categories : Java Script, Date Time, PHP
The toll booth
Categories : PHP, Java Script, Filesystem
MD5 secured login
Categories : PHP, Java Script, Authentication, Security
Dynamic generation of textboxes, select items etc in a table for use with databases applications, matrimonials and for job sites
Categories : PHP, HTML and PHP, Java Script