Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Send values to databse only if Payment was made.

Codes here !

Moderators: macek, egami, gesf

Send values to databse only if Payment was made.

Postby RafiGinat » Wed Aug 15, 2012 12:37 pm

I have a simple registration form that sends username and password to databse when you press submit.
I want that when the user press "submit" he needs to pay by paypal ( use paypal IPN ) and if he payd the user will be inserted into the datbase, if he didnt pay nothing will happen.

Thanks for any help !


Code: Select all
<html>
<head>
<title>New user registration</title>
</head>
<body>
<?php
include('db.php');
if(isset($_POST['submit']))
{
$username=$_POST['username'];
$password=$_POST['password'];
$err='';
   if($_POST['username']=="")
   {
       $err.="Please type username";
   }
   if($_POST['password']=="")
   {
       $err.="Please type password";
   }
   if($_POST['password']!=$_POST['password1'])
   {
      $err.="Password mismatch";
   }
   if($err=="")
   {
      $query=mysql_query("insert into tab (id,username, password) values('','$username','$password')");
      if($query)
      {
         echo "<script type='text/javascript'>alert('User registered successfully')</script>";
      }
      else
      {
         echo "<script type='text/javascript'>alert('there is a problem in user registration successfully')</script>";
      }
   }
   else
   {
      echo $err;
   }
}
else
{
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>"  method="post">
<h1>New user registration</h1><br><br>
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
Re-enter Password: <input type="password" name="password1"><br><br>
<input type="submit" name="submit">
</form>
<?php
}
?>
</body>
</html>
RafiGinat
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed Aug 15, 2012 12:33 pm

Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.