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
ok
Forum Contributor
Posts: 393 Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land
Post
by ok » Sun Jun 04, 2006 8:34 am
Code: Select all
$msg = "MESSAGE FROM SITE\n";
$msg .= "Sender's Name: $_POST[sender_name]\n";
$msg .= "Sender's E-Mail: $_POST[sender_email]\n";
$msg .= "Message: $_POST[message]\n\n";
$subject = "message from a user";
@mysql_connect("localhost","zzzzzzz","xxxxxxx");
@mysql_select_db("xxxxxxx") or die( "<CENTER> Couldnt find a database.");
$query = "SELECT `email`, `user` FROM users WHERE `user`='".$user."'";
$result = mysql_query($query);
$email = mysql_result($result, 0);
if(!$email)
{
die("Problem!!!");
}
//send the mail
mail($to, $subject, $msg, $mailheaders);
Where you define $user????
NAT
Forum Newbie
Posts: 24 Joined: Tue Mar 21, 2006 3:13 am
Post
by NAT » Sun Jun 04, 2006 8:50 am
NO this the script, and its not the user that searching for but the name, al i do is setting a link between the variables from this page to another page from the beginning of the script. And that how it searchis the name of a user and then selects the email adres from the database and takes the name of a user it in to a cache. Like this <span style='color:red;text-decoration:blink' title='Alert a moderator!'>grilled spam</span>:
http://www.xxx.com/from_mail.php?$name=NAT
Code: Select all
mysql_connect(localhost,"xxxxxxxx","xxxxxxxxx") or die(mysql_error());
mysql_select_db("xxxxxxxxxxxx") or die(mysql_error());
$query = "SELECT * FROM users WHERE name='".$name."'";
$result = mysql_query($query);
$email = mysql_result($result, 0,'email');
if(!$email)
{
die("Probleem!!!");
}
//Send the email
$subject = "xxxxxxxxxxxxxxx";
$message = "An mail form a user";
$headers = "To: $name <$email>\r\n";
$headers .= "From: <xxxx@xxxxxxxxxx.com>\r\n";
$headers .= "Reply-To: <xxx@xxxxx.com>\r\n";
mail($email, $subject, $message, $headers);
//display confirmation to user
echo "<P>Yuur message has been send!</p>";
but this is not the hole script, ofcourse. I can post the hole script if your want.
ok
Forum Contributor
Posts: 393 Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land
Post
by ok » Sun Jun 04, 2006 8:56 am
If you want to pass variables by using GET method you need to write it like that:
Code: Select all
http://www.xxx.com/from_mail.php?name=NAT
Notice that you
don't add a "$" !!!
NAT
Forum Newbie
Posts: 24 Joined: Tue Mar 21, 2006 3:13 am
Post
by NAT » Sun Jun 04, 2006 8:58 am
this is the code that paste of the beginnig of the script between <? ?>
like this: