hi,
i want to send email after redirecting on a page name email.php or it may be anything.when i redirect on this page amal should be send to user automatically.please send me a code for this please help me .thanks
irphan

use php mail script.... its available in php tutorial

Yes... U can send mail to the user by redirecting from one page to another page...

you can directly give the needed values to send mail in the redirected page or pass the values like to, from ,sub, message by the following.. Use redirecting code like this....

header("Location:email.php?to='sample@gmail.com'&sub='Sample'");

and you have to get this at redirected page as

$a=$_REQUEST;
$b=$_REQUEST;

and use this $a and $b in appropriate area in mail() function.. It perfectly works..

hope you can understand.. If any probs, please let me know....

if you are sending it to a user who signed up and his informations are recorded in your databases , then you can get his information by using $_SESSIOM and then you connect to mysql
check this code :

<?php
$con = mysql_connect("localhost","username","password");
if(!$con)
{
echo "error connecting to mysql server : ".mysql_error();
}
if(isset($_SESSIO['username']))
{
$username = $_SESSIO['username'];
$select = mysql_select("database_name");
if(!$select)
{
echo "cant select the database ".mysql_error();
}
$result = mysql_query("SELECT*FROM table_name WHERE username = '$username'");
if(!$result)
{
echo "cant select your datas from the db , please try again laiter ".mysql_error();
}
else
{
while($row = mysql_fetch_array($result))
{
$email = $row['email'];
$name = $row['username'];
$message = "Hello".$name."\n how r u , thank you for signing p and opening our page than this messgae is bla bla bla ba bla bla bla bla bla ";
email("$email","subject : to $name","$messsage");
echo "a message has been sent to your email ".$email."please open it and check it now ";
}
}
else
{
echo "please login";
header("location : login.php");
}
mysql_close();
?>

okay , idont know , as a biginner i think this is gonna work .i am not an expert in php so please if my code has any problem please vorrect mne
thanks

Hi Prince... Really i appreciate you a lot.. your code is perfect.. But session variable should be $_SESSION. Anyway, it will work fine...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.