Can't get it to send emails!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Can't get it to send emails!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Post by Mr. Tech »

Hi!

I have a script I have edited so that it sends emails. It allowed me to send emails on another page of the script but this page just WONT work!!! I have tried every way I know to send the email!! Heres the code:

Code: Select all

<?php ob_start(); ?>
<?
session_start();
// Unset all of the session variables.
session_unset();
// Finally, destroy the session.
session_destroy();
/*
if ($_GET('signup')) {
error("SIGNUP");
   echo "Error Checking<br>";
   while(list($name, $value) = each($signup)) {
      echo "$name - $value<br>";
   }
}
*/

   require 'include.inc';

    if ($signup) {
   
   	if ($signup[repassword] != $signup[password]) {
   		$err_msg = "Your passwords do not match.";
error($err_msg);
   	}
   
   	if(!eregi("^[_\.0-9a-z-]+$",$signup[username])) {
   		$err_msg = "Invalid Username! Usernames can consist of letters and numbers only.";
error($err_msg);   	
}
   	if(!eregi("^[_\.0-9a-z-]+$",$signup[password])) {
   	   $err_msg = "Invalid Password!  Passwords can consist of letters and numbers only.";
   	}
      if(!$signup[password] || !$signup[username] || !$signup[email] || !$signup[username])
            $err_msg = "Oops! You forgot some important fields!";


      if (!$err_msg) {

// =================================================================
The Send Email Part
// =================================================================
@mail("webmaster@webmaster-resources101.com","hi","hessage","From: Surf2Ya <support@surf2ya.com>");

	$time = time();
	$usercheck = @mysql_query("INSERT INTO user values(
      	'NULL','$signup[fname]','$signup[lname]',
      	'$signup[username]','$signup[password]','$signup[email]', 1, ".$pointInc.", '$signup[referral]', '$time', 'n', 'y', '0', '0', '')") or die ("<b>Error:</b> ".mysql_error());
      	
      	  // done, you are entered correctly, Now Enter the points and URL info
            
       
       		$sql = "Select id from user where username='$signup[username]'";

		$result = mysql_query( $sql );
			if ( $result != false )
				{
			while ( $data = mysql_fetch_assoc( $result ) )
			{
				$point_set = $data['id'];
		
				}
			} else {
				echo mysql_error();
			}	
		// add rerral points
	
	if ($signup[referral])	{
	  $referralSql="UPDATE points SET points=points+ ".$refPoints . " WHERE userid=".$signup[referral];
	  $result = mysql_query( $referralSql );
					if ( $result != false )
						{
					} else {
						echo mysql_error();
						}
        }							
		
		
	// add URL	
	
	$sql="INSERT INTO url_table ( userid, website, active, datechanged) VALUES ($point_set,'".$signup[site_url]."','n', '".date("Ymd")."')";

	  $result = mysql_query( $sql );
					if ( $result != false )
						{
					} else {
						echo mysql_error();
					}
	// add points
       	$sql="INSERT INTO points (userid, username, points) VALUES ($point_set,' ',$signPoints)";
	  $result = mysql_query( $sql );
					if ( $result != false )
						{
					} else {
						echo mysql_error();
						}
        }
         echo mysql_errno().": ".mysql_error()."<br>";
	
        	 	include ("reg.php"); 
        	 	exit;
         }
etc.. ect.. etc..
?>
Anything in the code that is stuffing it up?
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Code: Select all

// ================================================================= 
The Send Email Part 
// =================================================================
"The Send Email Part" text is not in comment form. Try:

Code: Select all

// ================================================================= 
//The Send Email Part 
// =================================================================
As for the rest of the code, I'm brand new to PHP.
User avatar
Saethyr
Forum Contributor
Posts: 182
Joined: Thu Sep 25, 2003 9:21 am
Location: Wichita, Kansas USA
Contact:

Post by Saethyr »

Wierd bro, worked fine on my server....did you try taking the @ off the front? I didn't have to but it might be worth a try.


Saethyr
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Do you know if you're actually getting into the SEND EMAIL portion of the script?

You could try changing this line:
if (!$err_msg) {

to:
if ($err_msg == "") {
or
if (empty($err_msg)) {
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Post by Mr. Tech »

Steveo31, that was something I added when posting the message :D

I was talking to the guy who owns the site and he says other scripts with email functions are also not working at the moment... So it must be the web host...

microthick, yes it is getting into the send email part. That's what so weird...

Thanks for your help!
Post Reply