Simple PHP mail script

This script is not only educational, but also applicable for practical Web development. It allows you to place a simple form for sending emails on any HTML page. The script shows you how to gather user input, perform form validation with PHP, and send an email.

First, make the form page mail.html (you may call it whatever you like)…

<head><title>Mail sender</title></head>
<form action="mail.php" method="POST">
<b>Email</b><br />
<input type="text" name="email" size=40/>
<p><b>Subject</b><br />
<input type="text" name="subject" size=40/>
</p><p><b>Message</b><br />
<textarea cols=40 rows=10 name="message"></textarea>
</p><p><input type="submit" value=" Send "/>

The form contains the necessary text fields Email, Subject, Message, and the Send button. The line

Continue reading Simple PHP mail script

Reading and writing a pixel color to the API help

Import System.Drawing namespace ,System.Runtime.InteropServices and System.Windows.Forms namespace .

using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
[DllImport( "user32.dll" )]
static extern IntPtr GetDC( IntPtr hWnd );
[DllImport( "user32.dll" )]
static extern int ReleaseDC( IntPtr hWnd, IntPtr hDC );
[DllImport( "gdi32.dll" )]
static extern int GetPixel( IntPtr hDC, int x, int y );
[DllImport( "gdi32.dll" )]
static extern int SetPixel( IntPtr hDC, int x, int y, int color );

static public Color GetPixel( Control control, int x, int y )
    Color color = Color.Empty;
    if (control != null)
        IntPtr hDC = GetDC( control.Handle );
        int colorRef = GetPixel( hDC, x, y );
        color = Color.FromArgb(
            (int)(colorRef & 0x000000FF),
            (int)(colorRef & 0x0000FF00) >> 8,
            (int)(colorRef & 0x00FF0000) >> 16 );
        ReleaseDC( control.Handle, hDC );
    return color;
static public void SetPixel( Control control, int x, int y, Color color )
    if (control != null)
        IntPtr hDC = GetDC( control.Handle );
        int argb = color.ToArgb();
        int colorRef =
            (int)((argb & 0x00FF0000) >> 16) |
            (int)(argb & 0x0000FF00) |
            (int)((argb & 0x000000FF) << 16);
        SetPixel( hDC, x, y, colorRef );
        ReleaseDC( control.Handle, hDC );

Collection Initilize NET 3.0 to up

Collection can I set the same time also to define.
Example 1

List<string> names = new List<string> {"Jack", "bill", "marin", "Sam"};

Example 2 – the assumption having class like:

public class Person
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public int Age { get; set; }

Can write:

List<Person> people = new List<Person> {
    new Person { FirstName = "Bill", LastName = "Gates", Age = 50 },
    new Person { FirstName = "Angelina", LastName = "Jolie", Age = 32 },
    new Person { FirstName = "Barack", LastName = "Obama", Age = 48}

Only the sample program can be run (using the Process) C#

Only the sample program can be run (using the Process)
Import using System.Diagnostics namespace

using System.Diagnostics;

These changes in the class apply to the StartUp program:

static class Program
    static void Main()
        if (IsPrevInstance())
        Application.Run(new Form1());

    private static bool IsPrevInstance()
        string processName = Process.GetCurrentProcess().ProcessName;
        Process[] instances = Process.GetProcessesByName(processName);
        if (instances.Length > 1)
            return true;
            return false;

Capture and import of screen C#

Add a Button and change its name to GetCapture and write this below code on Button’s Click event handler.

private void GetCapture_Click(object sender, EventArgs e)
this.BackgroundImage= CaptureScreen();

Write this below code on class Form

private Image CaptureScreen()
Bitmap screen = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
using (Graphics g = Graphics.FromImage(screen))
g.CopyFromScreen(0, 0, 0, 0, screen.Size);
return screen;

Get all printers listing in C#

Import System.Drawing.Printing namespace in your application.

using System.Drawing.Printing;

Add a DropDownList and change its name to printersList and write this below code on Form’s load event handler.

private void Form1_Load (object sender, System.EventArgs e)
 foreach (String printer in PrinterSettings.InstalledPrinters)
                    printersList.Items.Add (printer.ToString());

The DropDownList will show all printers available on your network.

Dynamically adding button to DataGrid C#

Dynamically add a button in DataGrid C # language easy
DataGridViewButtonColumn AddButton = new DataGridViewButtonColumn();
            AddButton.Name = "AddButton";
            AddButton.HeaderText = "AddButton";
            AddButton.Text = "AddButton";
            AddButton.Width = 70;
            AddButton.UseColumnTextForButtonValue = true;

Saving changes is not permitted (SQL Server 2008)

While creating and editing a database in SQL server 2008 I soon ran into a brick wall, or a ‘by design’ feature of the Database Management Studio.
When you design a table in a database and then try to make a change to a table structure that requires the table to be recreated, the Database Management Studio will not allow you to save the changes.
This is caused by a configuration setting that default results in the following dialog:

Error dialog

This dialog states: “Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created.”

You can only react clicking the Cancel button.
And than Management Studio shows this dialog:

So what you want to do to configure the setting with the value you want (IMHO should be the default setting!).
Go to: Tools > Options


Tools menu choose Options

Select the tab Designers and choose Tables and designers

And uncheck the option: “Prevent saving changes that require table re-creation”.
Once you now save changes it will work.

Slider by webdesign