mail(); just after "insert into _TABLE_ doesn't...

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
glennn3
Forum Commoner
Posts: 63
Joined: Sat Sep 20, 2003 8:43 pm

mail(); just after "insert into _TABLE_ doesn't...

Post by glennn3 »

this function is called from a Subscription form, clearly - i'm trying to send an email to the $name and $email address after a person registers,
just after 'INSERT INTO MEMBERS...' but for some reason the mail(); function doesn't work no matter where i put it. can someone please help?

Code: Select all

if($function=="subscribe")
{
	$name=$_POST["name"];
	$lastname=$_POST["lastname"];
	$street1=$_POST["street1"];
	$city=$_POST["city"];
	$state=$_POST["state"];
	$zip=$_POST["zip"];
	$country=$_POST["country"];
	$email=$_POST["email"];
	$username=$_POST["username"];
	$password=$_POST["password"];
	$narrative=$_POST["narrative"];
	$nn=$_POST["nn"];
	$ws=$_POST["ws"];
	
	$fields=array($name,$lastname,$street1,$city,$state,$zip,$country,$email,$username,$password);
	$fieldsverbose=array('name','lastname','street1','city','state','zip','country','email','username','password');
	
	$error="The following required fields were left blank:<br>";
	
	for($count=0;$count<count($fields);$count++)
	{
	
	if ($fields[$count]=="")
	  {
	    $error .= $fieldsverbose[$count];
	    $error .= "<br>";
	  }
	}
	
	
	$query="select * from members where (username=\"$username\")";
	$Result=mysql_query($query);
	if($row=mysql_fetch_array($Result))
	{
	print("<link rel=\"stylesheet\" href=\"../styleNM.css\" type=\"text/css\"><table><tr>
<td width='100'></td><td><br><br><br>The username \"$username\" is already taken.<br>
<a href=\"javascript:history.back();\">Click here</a> to go back and choose another.</td>
</tr></table>");
	}

	$query="select * from members where (password=\"$password\")";
	$Result=mysql_query($query);
	if($row=mysql_fetch_array($Result))
	{
	print("<link rel=\"stylesheet\" href=\"../styleNM.css\" type=\"text/css\"><table><tr>
<td width='100'></td><td><br><br><br>That password is already taken.<br>
<a href=\"javascript:history.back();\">Click here</a> to go back and choose another.</td>
</tr></table>");
	}
	else
	{

	if($narrative==1)
	{
		$nn=1;
		}
	$query="insert into members (name,lastname,street1,street2,city,state,zip,country,
email,username,password,narrative,nn,ws) values ('".$name."','".$lastname."','".$street1."','".$street2."',
'".$city."','".$state."','".$zip."','".$country."','".$email."','".$username."','".$password."','".
$narrative."','".$nn."','".$ws."')";

	if(mysql_query($query))
		setcookie('username', $username, time()+(60*60*24*30), '/', '', 0);
		print("<script language=\"javascript\">
				top.location=\"105/login.php\";
				</script>");
	}
}
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

i am sure when anyone reads your post, they would look for the line where you use the function mail() :) but you took that important part out

so, my only suggestion for you is to go here:
http://us3.php.net/manual/en/function.mail.php
glennn3
Forum Commoner
Posts: 63
Joined: Sat Sep 20, 2003 8:43 pm

Post by glennn3 »

here is where i've put the mail();: the odd thing is it works with no spaces in the 'From' parameter, but if i separate the From:NarrativeMagazine
to 'From: Narrative Magazine' then it doesn't work. and the mail comes as from 'NarrativeMagazine@luc.host-vault.com' --- someone please help? i've been able to figure this out before, but i've been out of work for awhile and don't remember...

Code: Select all

$query="insert into members (name,lastname,street1,street2,city,state,zip,country,email,username,password,narrative,nn,ws) values ('".$name."','".$lastname."','".$street1."','".$street2."','".$city."','".$state."','".$zip."','".$country."','".$email."','".$username."','".$password."','".$narrative."','".$nn."','".$ws."')";

       $email=$_POST["email"];
	mail($email,"test subject","tested","From:NarrativeMagazine");
glennn3
Forum Commoner
Posts: 63
Joined: Sat Sep 20, 2003 8:43 pm

Post by glennn3 »

got it, thanks for the link ---
Post Reply