Php ipn help

Hi,

I’m trying to get a user to register through a registration page and have that user entered into my sql db before being redirected to paypal. Before he pays the "activated column in datebase will be set to zero and afterwards paypal’s ipn will set the value to one…allowing him to login. I’m getting a few errors and I need a little help but before you do, realize that most of this code is a little advanced for me and i’ve learned what i know now from tutorials explaining the ipn process. So, Please explain any changes in the code

signup.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>none</title>
<meta name="description" content="add description here" />
<meta name="keywords" content="add keywords here" />
<link rel="stylesheet" type="text/css" href="../style.css"/>
<link rel="shortcut icon" href="#" /><!-- Add your favicon link here -->
</head>

<body>
<div id="wrapper">

<div id="header">
<div id="logo">
<a href="../index.html" title="back to homepage"><img src="../images/logo.png" alt="logo" /></a>
</div>
<span class="unlock">Unlock-An-Iphone</span>

<div id="right-header">
<div id="topnav">
<ul>
<li><a href="../index.html" title="Home">Home</a></li>
<li><a href="signup.php" title="Unlock Now">Unlock Now!</a></li>
<li><a href="../support.html" title="Support">Support</a></li>
<li><a href="../faq.html" title="Faq">F.A.Q</a></li>
</ul>
</div><!-- END topnav -->

<div class="cleaner"></div>
<span class="members"><a href="#" title="members login">members login</a></span>
</div><!-- right-header -->
</div><!-- END header -->

<div class="cleaner"></div>
<div id="content">


<div class="cleaner">
<center>
  <p><br />
    <font size="2" face="Arial, Helvetica, sans-serif"><span class="Login_Words"><strong> Membership  Sign-Up</strong></span></font><br />
    <br />
  </p>
  <form name="Signup" method="post" action="register.php" onsubmit="">
    <table width="525" border="0" cellpadding="2" cellspacing="0" id="STATIC_DATA">
      <tr>
        <td colspan="2" valign="top"></td>
      </tr>
      <tr>
        <td></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td width="235" class="Login_Words"><font size="2" face="Arial, Helvetica, sans-serif"><strong> First Name </strong></font></td>
        <td nowrap><span class="Sentry_fields">
          <input name="First_Name" type="text" size="40" maxlength="25" />
        </span> <span class="Login_Words">*</span></td>
      </tr>
      <tr>
        <td><font size="2" face="Arial, Helvetica, sans-serif"><span class="Login_Words"><strong> Last Name </strong></span></font></td>
        <td nowrap><span class="Sentry_fields">
          <input name="Last_Name" type="text" size="40" maxlength="35" />
        </span> <span class="Login_Words">*</span></td>
      </tr>
      <tr>
        <td><font size="2" face="Arial, Helvetica, sans-serif"><span class="Login_Words"><strong> E-mail Address </strong></span><br />
          </font><font size="1" face="Arial, Helvetica, sans-serif"><span class="Sentry_smallWords"> Must be valid. 
            
            
            
            Double check the accuracy of your e-mail address! You must click a verification 
            
            link that will be sent to this address. <br />
            <br />
          </span></font><font size="2" face="Arial, Helvetica, sans-serif"><strong> </strong></font></td>
        <td valign="middle" nowrap><span class="Sentry_fields">
          <input name="Email_ID" type="text" size="40" maxlength="50" oncopy="javascript:return false;" />
        </span> <span class="Login_Words">*</span></td>
      </tr>
      <tr>
        <td><font size="2" face="Arial, Helvetica, sans-serif"><span class="Login_Words"><strong> Re-enter E-mail Address </strong></span><br />
        </font></td>
        <td nowrap><span class="Sentry_fields">
          <input name="Email_ID2" type="text" size="40" maxlength="50" onpaste="javascript:return false;" />
        </span> <span class="Login_Words">*</span></td>
      </tr>
      <tr>
        <td width="235" class="Login_Words"><p><strong><font size="2" face="Arial, Helvetica, sans-serif">Username</font></strong></p></td>
        <td nowrap><span class="Sentry_fields">
          <input name="Username" type="text" size="40" maxlength="25" />
        </span> <span class="Login_Words">*</span></td>
      </tr>
      <tr>
        <td class="Login_Words"><font size="2" face="Arial, Helvetica, sans-serif"><strong> Create a Password </strong></font> <font size="1" face="Arial, Helvetica, sans-serif"><span class="Sentry_smallWords"><br />
          8 Characters minimum.<br />
          Letters and Numbers only, no symbols! </span> <br />
          <br />
          <span class="Sentry_smallWords"> Note: Payment is processed through PayPal. This will be your website Password, 
            
            not your PayPal Password. </span></font></td>
        <td valign="top" nowrap><span class="Sentry_fields">
          <input name="Password" type="password" size="40" maxlength="50" />
        </span> <span class="Login_Words">*</span></td>
     
      <tr>
        <td colspan="2" valign="top"><font size="1" face="Arial, Helvetica, sans-serif"><span class="Sentry_smallWords"> Payment will be processed through PayPal. </span></font><font size="2" face="Arial, Helvetica, sans-serif"><br />
          <br />
          &nbsp;</font><img src="../images/paypal_sub_btn.gif" width="62" height="31" />&nbsp;<img src="../images/logo_creditCards.gif" width="169" height="21" /><br />
      </tr>      <tr>
        <td colspan="3">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td background="../images/dot.gif"><img src="../images/spacer.gif" width="1" height="8" /></td>
          </tr>
        </table></td>
      </tr>
      <tr>
          <input type="submit" name="Submit_Button" value="  Next  " style="width:80px;" /></td>
      </tr>
    </table>
    <br />
</form>
    <!-- END CONTENT -->

  </p>
  <noscript>
  <div style="display:none;"> 
    <p><img src="//pixel.quantserve.com/pixel/p-12xlHBPmKcNd6.gif" height="1" width="1" alt="Quantcast" /> </p>
  </div>
  </noscript>
  <p>
    <!-- End Quantcast tag -->
  </p>
</center>
</div><!-- END content -->


<div class="cleaner"></div>
</div><!-- END wrapper -->

<div id="footer-bar">
<div id="footer-left"></div>
<div id="footer-mid">
<div id="footer-mid-text">100% Satisfaction	 -> 30 Day Money Back Guarantee</div>
<div class="readmore"><a href="../why.html" title="name"><img src="../images/readmore.jpg" alt="readmore" /></a></div>
<div class="cleaner"></div>
</div><!-- END footer-mid -->
<div id="footer-right"></div>
</div><!-- END footer-bar -->


<div id="bottom-wrap">
<div id="social-ftr">
<div class="social-but">
</div>
</div>

<div id="paypal">
<img src="../images/paypal.png" alt="paypal" />
</div>
</div><!-- END bottom-wrap -->



<div id="footer">
<div id="footerlinks">
<ul class="block">
<li><a href="../index.html" title="Home">Home</a></li>
<li><a href="../why.html" title="Why">Why?</a></li>
<li><a href="signup.php" title="Buy">Buy</a></li>
<li><a href="../faq.html" title="Faq">F.A.Q</a></li>
<li><a href="../support.html" title="Contact">Contact</a></li>
</ul>
<div class="copyright">&copy; . All rights reserved</div>
</div><!-- END footerlinks -->
</div><!-- END footer -->

</body>
</html>

This is where I am getting my first problem at the bottom I have an html form to send to the database. It will not send because of the last lineof the form to deal with the user_id…even when I tried to use php curl
Register.php


<?

include 'db.php';

// Define post fields into simple variables
$First_Name = $_POST['First_Name'];
$Last_Name = $_POST['Last_Name'];
$Email_ID = $_POST['Email_ID'];
$Username = $_POST['Username'];
$Password = $_POST['Password'];

/* Let's strip some slashes in case the user entered
any escaped characters. */

$First_Name = stripslashes($First_Name);
$Last_Name = stripslashes($Last_Name);
$Email_ID = stripslashes($Email_ID);
$Username = stripslashes($Username);
$Password = stripslashes($Password);


/* Do some error checking on the form posted fields */

if((!$First_Name) || (!$Last_Name) || (!$Email_ID) || (!$Username) || (!$Password)){
	echo 'You did not submit the following required information! <br />';
	if(!$First_Name){
		echo "First Name is a required field. <br /> Please enter it below.<br />";
	}
	if(!$Last_Name){
		echo "Last Name is a required field. <br /> Please enter it below.<br />";
	}
	if(!$Email_ID){
		echo "Email Address is a required field. <br /> Please enter it below.<br />";
	}
	if(!$Username){
		echo "Desired Username is a required field. <br /> Please enter it below.<br />";
        }
	if(!$Password){
		echo "Desired Password is a required field. <br /> Please enter it below.<br />";
	}
	include 'signup.php'; // Show the form again!
	/* End the error checking and if everything is ok, we'll move on to
	 creating the user account */
	exit(); // if the error checking has failed, we'll exit the script!
}
	
/* Let's do some checking and ensure that the user's email address or Username
 does not exist in the database */
 
 $sql_email_check = mysql_query("SELECT Email_ID FROM users WHERE Email_ID='$Email_ID'");
 $sql_Username_check = mysql_query("SELECT Username FROM users WHERE Username='$Username'");
 
 $email_check = mysql_num_rows($sql_email_check);
 $Username_check = mysql_num_rows($sql_Username_check);
 
 if(($email_check > 0) || ($Username_check > 0)){
 	echo "Please fix the following errors: <br />";
 	if($email_check > 0){
 		echo "<strong>Your email address has already been used by another member in our database. Please submit a different Email address!<br />";
 		unset($Email_ID);
 	}
 	if($Username_check > 0){
 		echo "The Username you have selected has already been used by another member in our database. Please choose a different Username!<br />";
 		unset($Username);
 	}
 	include 'signup.php'; // Show the form again!
 	exit();  // exit the script so that we do not create this account!
 }
 
/* Everything has passed both error checks that we have done.
It's time to create the account! */



// Enter info into the Database.
$info2 = htmlspecialchars($info);
$sql = mysql_query("INSERT INTO users (First_Name, Last_Name, Email_ID, Username, Password, signup_date)
		VALUES('$First_Name', '$Last_Name', '$Email_ID', '$Username', '$Password', '$db_password', '$info2', now())") or die (mysql_error());

if(!$sql){
	echo 'There has been an error creating your account. Please contact the webmaster at Admin@website.com';
} else {
?>
	  <form name="Signup" method="post" action="https://paypal.com/cgi-bin/webscr" >
	  <input type="hidden" name="cmd" value="_xclick">
      <input type="hidden" name="business" value="admin@website.com">
      <input type="hidden" name="item_name" value="Membership">
      <input type="hidden" name="item_number" value="1">
      <input type="hidden" name="amount" value="19.95">
      <input type="hidden" name="no_shipping" value="1">
      <input type="hidden" name="no_note" value="1">
      <input type="hidden" name="currency_code" value="USD">
      <input type="hidden" name="lc" value="US">
      <input type="hidden" name="return" value="http://website.com/members">
      <input type="hidden" name="cancel_return" value="http://website.com/Signup.php">
      <input type="hidden" name="rm" value="2">
      <input type="hidden" name="notify_url" value="http://website.com/ipn.php" />
      <input type="hidden" name="custom" value="<?php echo $_SESSION['User_ID']; ?>">

I am al gettin an error here at the end of the if statement…

$update_Activated = mysql_query(“UPDATE ‘users’ SET Activated=‘1’ WHERE ‘User_ID’='”.$User_ID.“'”);
im lost at this point but I need this code to update my users activated status…

ipn.php

<?php
require 'glob.inc.php';

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
  $value = urlencode(stripslashes($value));
  $req .= "&$key=$value";
}

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\\r\
";
$header .= "Content-Type: application/x-www-form-urlencoded\\r\
";
$header .= "Content-Length: " . strlen($req) . "\\r\
\\r\
";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$User_ID = mysql_real_escape_string((int)$_POST['custom')];  //the users ID

if (!$fp) {
   // HTTP ERROR
} else {
  fputs ($fp, $header . $req);
  while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, "VERIFIED") == 0) {
		
		if ($payment_status=='Completed') {
			$txn_id_check = mysql_query("SELECT 'txn_id' FROM 'log' WHERE 'TXN_ID'='".$txn_id."'");
			if (mysql_num_rows($txn_id_check) !=1) {
				
				if ($receiver_email=='admin@website') {
					
					if ($payment_amount=='19.95' && $payment_currency=='USD') {
						
						//add txn_id to db
						$log_query = mysql_query("INSERT INTO 'log' VALUES ('','".$txn_id."','".$payer_email."')") 
						
						//update Activated to 1
						$update_Activated = mysql_query("UPDATE 'users' SET Activated='1' WHERE 'User_ID'='".$User_ID."'");
					}
				}
			}
		}
    }
  }
  fclose ($fp);
}

?>

glob.inc.php

<?php
session_start();
// database connection
mysql_connect('localhost','username','password');
mysql_select_db('jcarr_paypal_members');

// premium check function
function is_Activated() {
	$Activated_query = mysql_query("SELECT 'Activated' FROM 'users' WHERE 'User_ID'='".$_SESSION['User_ID'
	$Activated = mysql_result($Activated_query, 0, 'Activated');
	if ($Activated=='1') {
	  return true;
	}
}

?>