Jump to content

Nightasy

Members
  • Posts

    65
  • Joined

  • Last visited

Everything posted by Nightasy

  1. I have verified that all the indexes are spelled correctly and the information being returned is all accurate.
  2. Alright, I got it set up to send back a Completed purchase but I am still not getting the database to update.
  3. Alright, I did that. While checking through the values I found out that the payment status is being returned from the fake sandbox account as PENDING. That would explain why it's stopping dead in it's tracks, now I need to figure out how to get the paypal sandbox to verify the payment for testing. Oh, and Thank you very much for your help. I'll look into this and get back to you.
  4. Ignore the email and url tags, I cant seem to stop the full editor from adding them in. Edit: I found the code button.
  5. Hello everyone, I'm having a real issue here with getting a paypal IPN to update the database. When I sandbox tested the IPN it connected successfully but when I used the sandbox to fake a real world transaction the database doesn't get updated. Here's the code for the form that I send to paypal. <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="POST"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="[email protected]"> <input type="hidden" name="item_name" value="private.com Lifetime Membership"> <input type="hidden" name="item_number" value="1"> <input type="hidden" name="amount" value="7.00"> <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="bn" value="PP-BuyNowBF"> <input type="hidden" name="return" value="http://private.com/login.php"> <input type="hidden" name="cancel_return" value="http://private.com"> <input type="hidden" name="rm" value="2"> <input type="hidden" name="notify_url" value="http://private.com/ipn.php" /> <input type="hidden" name="custom" value="<?php echo $_SESSION['username']; ?>"> <input type="submit" value="Activate Lifetime Membership"> </form> Here is the IPN code. <?php // Connect to database require 'config.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\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.sandbox.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']; $username = $_POST['custom']; // Identify User 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=='[email protected]'){ if ($payment_amount=='7.00' && $payment_currency=='USD'){ // add txn_id to database $log_query = mysql_query("INSERT INTO 'log' VALUES ('','".$txn_id."','".$payer_email."')"); // update premium to 1 $update_premium = mysql_query("UPDATE 'members' SET premium='1' WHERE 'username'='".$username."'"); } } } } } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation } } fclose ($fp); } ?> No matter what I have tried via scouring various search engines and forums I can not seem to find an answer to why this set up is not updating the databases. If anyone could please help I would appreciate it, this little snag is the only thing holding me back from launching the site. I should note that I am a rather novice coder so please do provide examples. Thank you much, Nightasy
  6. I found these scripts here: http://net.tutsplus....ation-with-php/ and they doesn't seem to be working anymore. Seems a bit more then I can figure out how to correct. The broken script is the last one of the three it appears. If anyone knows what is wrong with the IPN please let me know, I am searching for a means to accept payment on a membership based website and I am not having any luck. Seems all the paid membership tutorials available that I have found are all broken or out of date. The IPN when tested live with the correct settings doesn't do anything when paypal calls it. It doesn't create a user in the mysql database and it does not send any email. These are of course just the default codes from the link above. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""[url="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd[/url]"> <html xmlns="[url="http://www.w3.org/1999/xhtml"]http://www.w3.org/1999/xhtml[/url]"> <head> <title>Nettuts.com | Purchase access to download area</title> <link rel="stylesheet" type="text/css" media="All" href="css/style.css" /> </head> <body> <div id="wrap"> <h2>Purchase Access</h2> <p>Please click the button below to receive login details for the download area. <br /> Already have an account? <a href="login.php">Login</a> here.</p> Your PayPal Button Coder Here.... </div> </body> </html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""[url="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd[/url]"> <html xmlns="[url="http://www.w3.org/1999/xhtml"]http://www.w3.org/1999/xhtml[/url]"> <head> <title>Nettuts.com | Login</title> <link rel="stylesheet" type="text/css" media="All" href="css/style.css" /> </head> <body> <div id="wrap"> <?php mysql_connect("localhost", "user", "password") or die(mysql_error()); mysql_select_db("DBName") or die(mysql_error()); if(isset($_POST['email']) && isset($_POST['password'])){ // Verify $email = mysql_escape_string($_POST['email']); $password = md5($_POST['password']); $gUser = mysql_query("SELECT * FROM users WHERE email='".$email."' AND password='".$password."' LIMIT 1") or die(mysql_error()); $verify = mysql_num_rows($gUser); if($verify > 0){ echo '<h2>Login Complete</h2> <p>Click here to download our program</p>'; }else{ echo '<h2>Login Failed</h2> <p>Sorry your login credentials are incorrect.'; } }else{ ?> <h2>Login</h2> <p>Please enter your login credentials to get access to the download area</p> <form method="post" action=""> <fieldset> <label for="email">Email:</label><input type="text" name="email" value="" /> <label for="password">Password:</label><input type="text" name="password" value="" /> <input type="submit" value="Login" /> </fieldset> </form> <?php } ?> </div> </body> </html> IPN.php <?php mysql_connect("localhost", "user", "password") or die(mysql_error()); mysql_select_db("DBName") or die(mysql_error()); // 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\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { // PAYMENT VALIDATED & VERIFIED! $email = $_POST['payer_email']; $password = mt_rand(1000, 9999); mysql_query("INSERT INTO users (email, password) VALUES('". mysql_escape_string($email) ."', '".md5($password)."' ) ") or die(mysql_error()); $to = $email; $subject = 'Download Area | Login credentials'; $message = ' Thank you for your purchase Your account information ------------------------- Email: '.$email.' Password: '.$password.' ------------------------- You can now login at [url="http://yourwebsite.com/PayPal/'"]http://yourwebsite.com/PayPal/'[/url]; $headers = 'From:[email protected]' . "\r\n"; mail($to, $subject, $message, $headers); } else if (strcmp ($res, "INVALID") == 0) { // PAYMENT INVALID & INVESTIGATE MANUALY! $to = [email="'[email protected]'"]'[email protected]'[/email]; $subject = 'Download Area | Invalid Payment'; $message = ' Dear Administrator, A payment has been made but is flagged as INVALID. Please verify the payment manualy and contact the buyer. Buyer Email: '.$email.' '; $headers = 'From:[email protected]' . "\r\n"; mail($to, $subject, $message, $headers); } } fclose ($fp); } ?> Thanks for taking a look. It's a really simple layout and would work perfectly for what I am doing... if it worked.
  7. Yep, turns out that was the problem. Everything's working just fine now. Thanks for taking a look anyhow. In essence the code was failing because there was already a user with id of 1 in the data base. So when I tested it yesterday it worked fine because there was no user id 0. Then when I tested it today it was trying to create a user id 1 and there was already a user id 1 so the code was failing. So since it couldnt follow the increment, well, you get the point.
  8. Actually I think I might have found the error. When I created the default user to test the login page, I set the id to 1 instead of 0. Now I just deleted all users and got past the error. Testing it now.
  9. I get that, but the form only has 4 fields. It's a really simple form.
  10. There is currently only one user in the database. The user is a default user that I made to test the database connection file. I tested this register page yesterday after having reported a different error where I had added an s on the end of a function by accident. When I tested it yesterday it worked. Now I can't get it to create a new user and I get that error.
  11. Sorry, here you go. <?php error_reporting (E_ALL ^ E_NOTICE); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"]http://www.w3.org/TR...ransitional.dtd[/url]"> <html xmlns="[url="http://www.w3.org/1999/xhtml"]http://www.w3.org/1999/xhtml[/url]"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link href="CSS/oneColFixCtrHdr.css" rel="stylesheet" type="text/css" /> <style type="text/css"> body { background-attachment: fixed; background-image: url(Images/MainBackground.jpg); background-repeat: no-repeat; background-position: center center; } </style> </head> <body> <div class="container"> <div class="header"><!-- end .header --><img src="Images/SiteHeaderComplete.jpg" width="960" height="256" /></div> <div class="content"> <?php if ( $_POST['registerbtn']){ $getuser = $_POST['user']; $getemail = $_POST['email']; $getpass = $_POST['pass']; $getretypepass = $_POST['retypepass']; if ($getuser){ if ($getemail){ if ($getpass){ if ($getretypepass){ if ( $getpass === $getretypepass ){ if ( (strlen($getemail) >= 7) && (strstr($getemail, "@")) && (strstr($getemail, ".")) ){ require("./connect/connect.php"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $query = mysql_query("SELECT * FROM users WHERE email='$getemail'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $password = md5(md5("82dWa89dw7a".$getpass."F904Hh88w8hjOoiIilLiI")); $date = date("F d, Y"); $code = md5(rand()); mysql_query("INSERT INTO users VALUES ( '', '$getuser', '$password', '$getemail', '0', '$code', '$date' )"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 1){ $site = "[url="http://www.editedoutforprivacy.com"]http://www.editedoutforprivacy.com[/url]"; $webmaster = "Nightasy <[email="[email protected]"][email protected][/email]>"; $headers = "From: $webmaster"; $subject = "Activate your account."; $message = "Thank you for registering at editedoutforprivacy.com. Please click the link below to activate your account.\n"; $message .= "$site/activate.php?user=$getuser&code=$code\n"; $message .= "You must activate your account to login."; if ( mail($getemail, $subject, $message, $headers)){ $errormsg = "You have been registered. In order to complete the registration you must activate your account from the email sent to <b>$getemail</b>"; $getuser = ""; $getemail = ""; } else $errormsg = "An error has occured. Your activation email was not sent."; } else $errormsg = "An error has occured. Your account was not created."; } else $errormsg = "That email is already in use."; } else $errormsg = "That username is already taken."; mysql_close(); } else $errormsg = "You must enter a valid email to register."; } else $errormsg = "Your passwords did not match."; } else $errormsg = "You must retype your password to register."; } else $errormsg = "You must enter your password to register."; } else $errormsg = "You must enter your email to register."; } else $errormsg = "You must enter your username to register."; } $form = "<form action='./register.php' method='post'> <table> <tr> <td></td> <td><font color='red'>$errormsg</font></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='user' value='$getuser' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' value='$getemail' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='pass' value='' /></td> </tr> <tr> <td>Confirm Password:</td> <td><input type='password' name='retypepass' value='' /></td> </tr> <tr> <td></td> <td><input type='submit' name='registerbtn' value='Register' /></td> </tr> </table> </form>"; echo $form; ?> <!-- end .content --></div> <div class="footer"> <p>Footer</p> <!-- end .footer --></div> <!-- end .container --></div> </body> </html>
  12. Greetings, Weirdly enough, this page worked yesterday and now it will not work. I'm not sure what the issue is. The error I am recieving is. An error has occured. Your account was not created. Here is the entire page: <?php error_reporting (E_ALL ^ E_NOTICE); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/url]"> <html xmlns="[url="http://www.w3.org/1999/xhtml"]http://www.w3.org/1999/xhtml[/url]"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link href="CSS/oneColFixCtrHdr.css" rel="stylesheet" type="text/css" /> <style type="text/css"> body { background-attachment: fixed; background-image: url(Images/MainBackground.jpg); background-repeat: no-repeat; background-position: center center; } </style> </head> <body> <div class="container"> <div class="header"><!-- end .header --><img src="Images/SiteHeaderComplete.jpg" width="960" height="256" /></div> <div class="content"> <?php if ( $_POST['registerbtn']){ $getuser = $_POST['user']; $getemail = $_POST['email']; $getpass = $_POST['pass']; $getretypepass = $_POST['retypepass']; if ($getuser){ if ($getemail){ if ($getpass){ if ($getretypepass){ if ( $getpass === $getretypepass ){ if ( (strlen($getemail) >= 7) && (strstr($getemail, "@")) && (strstr($getemail, ".")) ){ require("./connect/connect.php"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $query = mysql_query("SELECT * FROM users WHERE email='$getemail'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $password = md5(md5("82dWa89dw7a".$getpass."F904Hh88w8hjOoiIilLiI")); $date = date("F d, Y"); $code = md5(rand()); mysql_query("INSERT INTO users VALUES ( '', '$getuser', '$password', '$getemail', '0', '$code', '$date' )"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 1){ $site = "[url="http://www.editedoutforprivacy.com"]http://www.editedoutforprivacy.com[/url]"; $webmaster = "Nightasy <[email="[email protected]"][email protected][/email]>"; $headers = "From: $webmaster"; $subject = "Activate your account."; $message = "Thank you for registering at editedoutforprivacy.com. Please click the link below to activate your account.\n"; $message .= "$site/activate.php?user=$getuser&code=$code\n"; $message .= "You must activate your account to login."; if ( mail($getemail, $subject, $message, $headers)){ $errormsg = "You have been registered. In order to complete the registration you must activate your account from the email sent to <b>$getemail</b>"; $getuser = ""; $getemail = ""; } else $errormsg = "An error has occured. Your activation email was not sent."; } else $errormsg = "An error has occured. Your account was not created."; } else $errormsg = "That email is already in use."; } else $errormsg = "That username is already taken."; mysql_close(); } else $errormsg = "You must enter a valid email to register."; } else $errormsg = "Your passwords did not match."; } else $errormsg = "You must retype your password to register."; } else $errormsg = "You must enter your password to register."; } else $errormsg = "You must enter your email to register."; } else $errormsg = "You must enter your username to register."; } $form = "<form action='./register.php' method='post'> <table> <tr> <td></td> <td><font color='red'>$errormsg</font></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='user' value='$getuser' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' value='$getemail' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='pass' value='' /></td> </tr> <tr> <td>Confirm Password:</td> <td><input type='password' name='retypepass' value='' /></td> </tr> <tr> <td></td> <td><input type='submit' name='registerbtn' value='Register' /></td> </tr> </table> </form>"; echo $form; ?> <!-- end .content --></div> <div class="footer"> <p>Footer</p> <!-- end .footer --></div> <!-- end .container --></div> </body> </html> Does anyone have any idea what I might have done wrong or what is wrong with this page? Thanks in advance.
  13. OMG!!! Herp derp.... Thanks. Jesus, I can't believe that I didn't see that.
  14. Greetings all, I am developing a php website and I found a video series that showed me how to create a members system. Ran into an error and I am recieving this error. Fatal error: Call to undefined function mysql_nums_rows() in ....register.php on line 48 Here is the page code. <?php if ( $_POST['registerbtn']){ $getuser = $_POST['user']; $getemail = $_POST['email']; $getpass = $_POST['pass']; $getretypepass = $_POST['retypepass']; if ($getuser){ if ($getemail){ if ($getpass){ if ($getretypepass){ if ( $getpass === $getretypepass ){ if ( (strlen($getemail) >= 7) && (strstr($getemail, "@")) && (strstr($getemail, ".")) ){ require("./connect/connect.php"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); (this would be line 48) ---> $numrows = mysql_nums_rows($query); if ($numrows == 0){ $query = mysql_query("SELECT * FROM users WHERE email='$getemail'"); $numrows = mysql_nums_rows($query); if ($numrows == 0){ $password = md5(md5("edited out for privacy")); $date = date("F d, Y"); $code = md5(rand()); mysql_query("INSERT INTO users VALUES ('', '$getuser', '$password', '$getemail', '0', '$code', '$date')"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 1){ $site = "edited out for privacy"; $webmaster = "edited out for privacy <edited out for privacy>"; $headers = "From: $webmaster"; $subject = "Activate your account."; $message = "Thank you for registering at .... Please click the link below to activate your account.\n"; $message .= "$site/activate.php?user=$getuser&code=$code\n"; $message .= "You must activate your account to login."; if ( mail($getemail, $subject, $message, $headers)){ $errormsg = "You have been registered. In order to complete the registration you must activate your account from the email sent to <b>$getemail</b>"; $getuser = ""; $getemail = ""; } else $errormsg = "An error has occured. Your activation email was not sent."; } else $errormsg = "An error has occured. Your account was not created."; } else $errormsg = "That email is already in use."; } else $errormsg = "That username is already taken."; mysql_close(); } else $errormsg = "You must enter a valid email to register."; } else $errormsg = "Your passwords did not match."; } else $errormsg = "You must retype your password to register."; } else $errormsg = "You must enter your password to register."; } else $errormsg = "You must enter your email to register."; } else $errormsg = "You must enter your username to register."; } $form = "<form action='./register.php' method='post'> <table> <tr> <td></td> <td><font color='red'>$errormsg</font></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='user' value='$getuser' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' value='$getemail' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='pass' value='' /></td> </tr> <tr> <td>Confirm Password:</td> <td><input type='password' name='retypepass' value='' /></td> </tr> <tr> <td></td> <td><input type='submit' name='registerbtn' value='Register' /></td> </tr> </table> </form>"; echo $form; ?> Does anyone know where I screwed up here? Thanks in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.