Showing posts with label PHP. Show all posts
Monday, May 21, 2012
How to send email in PHP
index.html
mail.php
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
</head>
<body>
<center>
<table border="1" bgcolor="red">
<tr>
<td>
<form name="form" method="post" action="mail.php">
<center>To: <input type="text" name="to"><br></center>
<center>From: <input type="text name="from"><br></center>
<center>Subject: <input type="text" name="subject"><br></center>
<center>Message:<br><textarea name="message" rows=4 cols=25></textarea></center><br>
<center><input type="submit" value="send"></center>
</td>
</tr>
</body>
</html>
mail.php
<?php
$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$from = $_POST ['from'];
$headers = "From: $from";
// Please specify your Mail Server - Example: mail.yourdomain.com.
ini_set("SMTP","emailserver.sample.data.com");
// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
ini_set("smtp_port","25");
// Please specify the return address to use
ini_set('anuradha@xyz.com', 'anuradha@xyz.com');
$message = '<html><body>';
$message .= '<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['req-name']) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['from']) . "</td></tr>";
$message .= "<tr><td><strong>Comments:</strong> </td><td>" . strip_tags($_POST['message']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
$mail_sent = @mail( $to, $subject, $message, $headers );
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
Thursday, May 17, 2012
Username Password in WAMPServer MYSQL
If you have wamp installed , and if you would like to know how to create username and password in mysql.
Go to http://localhost/phpmyadmin [if port changes for WAMP server use http://localhost:8080/phpmyadmin]
and click on the Privileges tab. There is a "Add a new user" link.
In short, you create a user by running a CREATE USER statement:
CREATE USER "" IDENTIFIED BY "";
Once the user is created, you give him access to do things by using the GRANT statement.
Go to http://localhost/phpmyadmin [if port changes for WAMP server use http://localhost:8080/phpmyadmin]
and click on the Privileges tab. There is a "Add a new user" link.
In short, you create a user by running a CREATE USER statement:
CREATE USER "
Once the user is created, you give him access to do things by using the GRANT statement.
Could not execute menu item (internal error) :The service has not been started
When working with WampServer the icon always stays yellow/orange and never turns green. I found the solution! under Apache open the httpd.conf and change the lines #Listen 12.34.56.78:80 Listen 80 to #Listen 12.34.56.78:80 Listen 8080 Save the file and select “restart all services” it works! That just means that something has captured port 80 before apache can get hold of it. If you would like to know how to find the offending process. Open a command window "Run As Administrator". Then run >netstat -aon Look at the output under the "Local Address" column for something using :80
Subscribe to:
Posts
(
Atom
)