0

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

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Dragonbaki
0

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....

0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.