Link in Email to redirect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joycesolomon
Forum Newbie
Posts: 1
Joined: Mon Dec 21, 2009 3:26 pm

Link in Email to redirect

Post by joycesolomon »

Hi All

I am new to php and wanting some help. I need to create a script that emails active articles in my KB to my engineers with the link embedded in the email.
My problem is , once the email reached, the engineer clicks on a link, the login box need to prompt, and he enters his id and password, and once that is authenticated, it has to redirect to the url of the article that he clicked.

Here is a script that i have come so far...

<?php
$headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$dbuser="<id>";
$dbpass="<password>";
$dbname="<database>";
$chandle = mysql_connect("localhost", $dbuser, $dbpass) or die("Connection Failure to Database");
mysql_select_db($dbname, $chandle[/color]) or die ($dbname . " Database not found. " . $dbuser);
$mainsection="faqdata"; //The name of the table
$mainsection1="faqnewarticles"; //The name of the table

$query3=sprintf("TRUNCATE faqnewarticles");
$query=sprintf("INSERT INTO faqnewarticles SELECT
faqdata.id,
faqdata.active,
faqdata.thema,
faqdata.datum,
faqcategoryrelations.category_id,
NULL
FROM
faqdata,
faqcategoryrelations
WHERE
faqcategoryrelations.record_id = faqdata.id AND
faqdata.active = 'No'
");
$query2=sprintf("UPDATE faqnewarticles SET newdate = (SELECT LEFT(cast(faqnewarticles.datum as datetime),10))");
$query1=sprintf("SELECT faqnewarticles.thema,faqnewarticles.newdate, faqnewarticles.id, faqnewarticles.category FROM faqnewarticles WHERE faqnewarticles.newdate >= date_sub(curdate(), interval 2 week)");

$result3 = mysql_db_query($dbname, $query3) or die("Failed Query of " . $query3); //do the query
$result1 = mysql_db_query($dbname, $query) or die("Failed Query of " . $query); //do the query
$result2 = mysql_db_query($dbname, $query2) or die("Failed Query of " . $query2); //do the query
$result = mysql_db_query($dbname, $query1) or die("Failed Query of " . $query1); //do the query

$i=0;
while($row = mysql_fetch_array($result))
{
$result_array[$i] = $row;
$i++;
}
$to = "jsolomon@mitchellwayne.com";
$subject = "KB Portal has new articles";
for ($j=0;$j<count($result_array);$j++)
{
$id=$result_array[$j]['id'];
$thema=$result_array[$j]['thema'];
$category=$result_array[$j]['category'];
//$body .= "\n".$result_array[$j]."\n";
$body .= "<br><a href= \"http://kb.hosted.mwedc.com/faq/index.ph ... a."</a><br>";
}
mail($to, $subject,$body, $headers) ;
//mail($to, $subject,$body) ;
mysql_close($chandle);
?>
indian98476
Forum Commoner
Posts: 78
Joined: Tue Dec 15, 2009 3:24 am

Re: Link in Email to redirect

Post by indian98476 »

you can use the same page that you have for your login page for the website or another option is to redirect the link to a login page whereon it is passed to the contents.....
Post Reply