Jump to content

Php/mysql register form with paypal


Olavi

Recommended Posts

I have simple mysql/php register script. 

Now i need when register click submit then save all data database and then resdict to paypal pay now page. 

And when payment success then save database "Payment success" and then resdict to another page.

If "Payment canceled" then show messages "You cancelled payment" And resdict to page where is some text information.

Can someone help me little bit about that? :)

<?php include "base.php"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title></title>
<link rel="stylesheet" type="text/css" href="style1.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://www.modernizr.com/downloads/modernizr-latest.js"></script>
<script type="text/javascript" src="placeholder.js"></script>
</head>  
<body>  

<?php
if(!empty($_POST['username']) && !empty($_POST['password']))
{
	$username = mysql_real_escape_string($_POST['username']);
    $password = md5(mysql_real_escape_string($_POST['password']));
    $email = mysql_real_escape_string($_POST['email']);
    
	 $checkusername = mysql_query("SELECT * FROM users WHERE Username = '".$username."'");
     
     if(mysql_num_rows($checkusername) == 1)
     {
     	echo "<h1>Error</h1>";
        echo "<p>Sorry, that username is taken. Please go back and try again.</p>";
     }
     else
     {
     	$registerquery = mysql_query("INSERT INTO users (Username, Password, EmailAddress) VALUES('".$username."', '".$password."', '".$email."')");
        if($registerquery)
        {
        	echo "<h1>Success</h1>";
        	echo "<p>Your account was successfully created. Please <a href=\"index.php\">click here to login</a>.</p>";
        }
        else
        {
     		echo "<h1>Error</h1>";
        	echo "<p>Sorry, your registration failed. Please go back and try again.</p>";    
        }    	
     }
}
else
{
	?>
<form method="post" action="register.php" name="registerform" id="registerform">
		<label for="username">Username:</label><input type="text" name="username" id="username" class="placeholder" placeholder="Username"/><br />
		<label for="password">Password:</label><input type="password" name="password" id="password" class="placeholder" placeholder="Password"/><br />
        <label for="email">Email Address:</label><input type="email" name="email" id="email" class="placeholder" placeholder="Email"/><br />
		<input type="submit" name="register" id="register" value="Register" />
	</form>
    
	
	
	
   <?php
}
?>

</body>
</html>

 

 

Link to comment
Share on other sites

<?php include "base.php"; ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title></title>

<link rel="stylesheet" type="text/css" href="style1.css" />

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

<script src="http://www.modernizr.com/downloads/modernizr-latest.js"></script>

<script type="text/javascript" src="placeholder.js"></script>

</head>

<body>

 

<?php

if(!empty($_POST['username']) && !empty($_POST['password']))

{

$no = no;

$username = mysql_real_escape_string($_POST['username']);

$password = md5(mysql_real_escape_string($_POST['password']));

$email = mysql_real_escape_string($_POST['email']);

 

$checkusername = mysql_query("SELECT * FROM users WHERE Username = '".$username."'");

 

if(mysql_num_rows($checkusername) == 1)

{

echo "<h1>Error</h1>";

echo "<p>Sorry, that username is taken. Please go back and try again.</p>";

}

else

{

$registerquery = mysql_query("INSERT INTO users (Username, Password, EmailAddress, Payment) VALUES('".$username."', '".$password."', '".$email."', '".$no."')");

if($registerquery)

{

echo "<h1>Success</h1>";

echo "<p>Your account was successfully created. Please <a href=\"index.php\">click here to login</a>.</p>";

}

else

{

echo "<h1>Error</h1>";

echo "<p>Sorry, your registration failed. Please go back and try again.</p>";

}

}

}

else

{

?>

<form method="post" action="https://www.paypal.com/cgi-bin/webscr" name="registerform" id="registerform" target="_top">

<label for="username">Username:</label><input type="text" name="username" id="username" class="placeholder" placeholder="Username"/><br />

<label for="password">Password:</label><input type="password" name="password" id="password" class="placeholder" placeholder="Password"/><br />

<label for="email">Email Address:</label><input type="email" name="email" id="email" class="placeholder" placeholder="Email"/><br />

<input type="hidden" name="cmd" value="_s-xclick">

<input type="hidden" name="hosted_button_id" value="">

<input type="submit" name="register" id="register" value="Register" />

</form>

 

 

</form>

 

 

<?php

}

?>

<?php

 

// STEP 1: Read POST data

 

// reading posted data from directly from $_POST causes serialization

// issues with array data in POST

// reading raw POST data from input stream instead.

$raw_post_data = file_get_contents('php://input');

$raw_post_array = explode('&', $raw_post_data);

$myPost = array();

foreach ($raw_post_array as $keyval) {

$keyval = explode ('=', $keyval);

if (count($keyval) == 2)

$myPost[$keyval[0]] = urldecode($keyval[1]);

}

// read the post from PayPal system and add 'cmd'

$req = 'cmd=_notify-validate';

if(function_exists('get_magic_quotes_gpc')) {

$get_magic_quotes_exists = true;

}

foreach ($myPost as $key => $value) {

if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {

$value = urlencode(stripslashes($value));

} else {

$value = urlencode($value);

}

$req .= "&$key=$value";

}

 

 

// STEP 2: Post IPN data back to paypal to validate

 

$ch = curl_init('https://www.paypal.com/cgi-bin/webscr');

curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $req);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));

 

// In wamp like environments that do not come bundled with root authority certificates,

// please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path

// of the certificate as shown below.

// curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');

if( !($res = curl_exec($ch)) ) {

// error_log("Got " . curl_error($ch) . " when processing IPN data");

curl_close($ch);

exit;

}

curl_close($ch);

 

 

// STEP 3: Inspect IPN validation result and act accordingly

$yes= yes;

if (strcmp ($res, "VERIFIED") == 0) {

// check whether the payment_status is Completed

$payment_status = $_POST['payment_status'];

 

 

 

 

}

?>

<?php

error_reporting(E_ALL ^ E_NOTICE);

// MySQL uhendus

$user= "u843446384_auto";

$password="";

$database= "u843446384_auto";

$con="mysql";

mysql_connect($con,$user,$password);

@mysql_select_db($database) or die( "Unable to select database");

 

mysql_query("UPDATE users (Username, Password, EmailAddress, Payment) VALUES('".$username."', '".$password."', '".$email."', '".$yes."')");

mysql_close();

?>

 

 

</body>

</html>

 

 

Is it right?

Link to comment
Share on other sites

 

Computer Gaming Is A Good Channel for Learning

 

Gaming has been the number one hobby or diversion children have these days.Gone were the days that we go biking with our friends or any outdoor game there is to do.Due to the advancement in technology, children now have been inclined into these games 鈥?well, even adults too!We should just guide children to put these games as a number one source for learning.Computer games facilitate brain exercise which is really good for kids and adults alike.These computers develop a person鈥檚 analytical, ACCU Dell 312-0058 mastery and concentration skills.Because children have ready access to computers at school and at home, this may be a great source for learning for them.We should take into consideration the good effects of these games rather than only looking at the notion of having bad effects on children.We need not learn this from a course or whatsoever, this is life鈥檚 fact that each of us should know.Even games like chess, puzzle games or scrabble are now ACCU Dell U444C available in computer games.These games are good examples of computer games people could learn a lot.Most were designed to entertain and educate children and adults.Now, even children as early as kindergarten have tablets or computers to play on.There are so many applications you can download to be able to help them in their early learning.We should thank the 鈥済eeks鈥?of the various big computer companies for developing these kinds of gadgets or games.I have always had a positive attitude towards these technological advancements.Not only that I could easily share my thoughts in ACCU Dell 312-0028 this post to various readers around the world but I also learn so much in the Internet.You could find practically any topic you would want to learn about in the Internet.From a long day鈥檚 work, why not treat yourself with a game that would relieve your stress?Be it Role Playing Games, adventure, fantasy or brain concentration games, this is now one of the best channel for learning, not to mention one of the best way for entertainment.Of course, to attain the best gaming experience you would want to achieve, a good computer unit and computer gaming accessories are a must!A good internet connection is also important as most great games can be found online- mostly for free!So, get qualitycomputer gaming accessoriesand experience gaming like no other.

http://blogpings.com/blog/623/accu-acer-as09f34/

http://raovathn.net/index.php?do=/blog/3019/as09f34/

http://doggieblogs.com/blog/22319/batterij-acer-as09f34/

http://ramasocial.com/index.php?do=/blog/3608/as09f34/

http://www.eyemet.fr/index.php?do=/blog/1156/replacing-your-dell-3110-toner-cartridges-for-the-lowest-price/

http://www.baselwatchexpo.com/index.php?do=/blog/4/new-latest-dell-laptops/

http://walkwalls.com/index.php?do=/blog/104/how-to-buy-a-dell-latitude-d620-battery-online/

http://www.naijabros.com/index.php?do=/blog/1229/as09f34/

 

acerguestbook

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.