Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 4 of 4

Thread: Newsletter submit / subscribe php not working ?

  1. #1
    joecalardo is offline Member
    Join Date
    May 2011
    Posts
    61

    Default Newsletter submit / subscribe php not working ?

    Is there anyone that could take a look at my code my subscribe php isn't working, I've tried submitting my own e-mail etc and I get nothing, no spam no inbox nothing tried with 3 e-mails, not a single thing. Leaves me to think something wrong with the php code ...

    Code:
    <?php
    	header(”Cache-Control: cache, must-revalidate”);
    	header(”Pragma: public”);
    	//connect to db
    	include('db_connect.php');
    	//get variables from flash
    	$my_email = $_REQUEST["myEmail"];
    	$my_email = stripslashes($my_email); 
    	$user_name = $_REQUEST["myName"];
    	$user_name = stripslashes($user_name); 
    	$my_subscr = $_REQUEST["myStatus"];
    	//the message that gets sent
    	$subSubject = "Thanks for joining Farralane's mailing list $user_name!";//subject line if they are subscribing
    	$unsubSubject = "Mailing list removal confirmation";//subject line if they are being removed
    	$subBody = "Dear $user_name,\n\nThanks for joining the mailing list!\nWe will periodically send you great deals and special offers.";//body if they are subscribing
    	$unsubBody = "Dear $user_name,\n\nWe are sorry to see you go. Please consider joining again sometime in the future.";//body if they are being removed
    	$from = "grandcentral@leftrockdesign.com";//Who the email is from 
    	//search the db for this email
    	$find_query = "SELECT * FROM $table WHERE user_email = '$my_email'";
    	$find_result = mysql_query($find_query) or die("Invalid query: " . mysql_error() . "<br>". $find_query);
    	while($row = mysql_fetch_array($find_result)){
    		$email = $row['user_email'];
     	}
    	if(!$email){
    		//if this email doesnt exist add it to the db
    		$new_query = "INSERT INTO $table
    		(user_email, user_name, user_subscr)
    		values ('$my_email', '$user_name', '$my_subscr')"; 
    		$new_result = mysql_query($new_query) or die("Invalid query: " . mysql_error() . "<br>". $new_query);
    	}else{
    		//if the email does exist modify it
    		$edit_query = "SELECT * FROM `$table`";
    		$edit_result = mysql_query("UPDATE $table SET 
    		user_subscr='$my_subscr', 
    		user_name='$user_name' 
    		WHERE user_email='$my_email'");
    		$edit_result = mysql_query($edit_query) or die("Invalid query: " . mysql_error() . "<br><br>". $edit_query);
    	}	
    	
    	//email conformation
    	$from = "From: $from\r\n";
    	if($my_subscr == 1){
    		$subject = $subSubject;
    		$body = $subBody;
    		mail($my_email, $subject, $body, $from);
    	}else if($my_subscr == 0){
    		$subject = $unsubSubject;
    		$body = $unsubBody;
    		mail($my_email, $subject, $body, $from);
    	}
    ?>

  2. #2
    DotNetDevelopments is offline Senior Member
    Join Date
    Jul 2008
    Location
    Harlow / Essex / UK
    Posts
    619

    Default

    Just a quick glance.

    -My code here was wrong so I removed it, too much C# coding! -

    Have you tried to run the code directly?

    Also why are you using REQUEST? You should use POST or GET for security.

    Are you getting any errors at all?
    Last edited by DotNetDevelopments; 06-01-2011 at 07:09 AM.
    =====
    Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
    Execution Mode: 64 Bit
    Dot Net Developments - E-commerce By Experience

  3. #3
    joecalardo is offline Member
    Join Date
    May 2011
    Posts
    61

    Default

    Where could I try putting that code in ? And also ...could it be maybe if I don't have a newsletter signup? I don't see anything where I could see anyone who's put in their e-mail information, or even what e-mail they would be getting, what are in the contents etc? How can I even tell if someone has put an e-mail already, and also, where could I find what the e-mail that will be sent out, is located?

  4. #4
    DotNetDevelopments is offline Senior Member
    Join Date
    Jul 2008
    Location
    Harlow / Essex / UK
    Posts
    619

    Default

    ASPDNSF has a newsletter feature built in...

    I was wrong what I said first, I forgot that in PHP you can call a variable inside a string as long as it is made with double quotes. Never call them in the string personally, always break the string and do a join so bad moment for me there.

    Are you getting any records in your database?
    =====
    Version (Code/DB): AspDotNetStorefront MSx 9.1.0.1/9.1.0.0
    Execution Mode: 64 Bit
    Dot Net Developments - E-commerce By Experience