Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

my full code for beginers to be able to have a paying login system.

Recommended Posts

I thort i shall shere i just learn this and it going to be handy for beginers.


Whith this code a user selects how many months they want to subcribe to a website, the database updates and enters the exspire_date according to the months the user wants and also update the payment per month.

the whole idear is that a user choose the months they want to subcribe for the database gets all relevent data and then you send them to paypal o pay via there price monthly plan.

was good fun hope this is helpfull.



[code]
<?php

$db=mysql_connect("localhost","xxx","xxx");
mysql_select_db("testcode",$db);



$id=addslashes($_POST['id']);
$payment_months=addslashes($_POST['payment_months']);
$exspire_date=addslashes($_POST['exspire_date']);
$price=addslashes($_POST['price']);



$id="02";

if($_POST['submit']){

$insert="INSERT INTO members (id,payment_months,exspire_date,price)values('$id','$payment_months',
'$exspire_date','$price')";

$insert=mysql_query($insert);

}

?>


<?php

$db=mysql_connect("localhost","root","admin");
mysql_select_db("testcode",$db);


$query1="select payment_months, exspire_date, price from members where id=2 ";
$result1=mysql_query($query1);


while($payment_months=mysql_fetch_assoc($result1)){

$months=$payment_months['payment_months'];



if($months==1){

$m=date("m")+1;

$date_know=date("d-$m-y");

$changed_date=strtotime($date_know);

$exspire_new=$payment_months['exspire_date']+$changed_date;

$query2="update members set price='£5',exspire_date=$exspire_new where id=2 ";

$result2=mysql_query($query2); 



}elseif($months==2){

$m=date("m")+2;

$date_know=date("d-$m-y");

$changed_date=strtotime($date_know);

$exspire_new=$payment_months['exspire_date']+$changed_date;

$query3="update members set  price='£10',exspire_date=$exspire_new where id=2";   

$result3=mysql_query($query3);



}elseif($months==3){

$m=date("m")+3;

$date_know=date("d-$m-y");

$changed_date=strtotime($date_know);

$exspire_new=$payment_months['exspire_date']+$changed_date;

$query4="update members set  price='£15',exspire_date=$exspire_new where id=2"; 

$result4=mysql_query($query4);



}elseif($months==4){

$m=date("m")+4;

$date_know=date("d-$m-y");

$changed_date=strtotime($date_know);

$exspire_new=$payment_months['exspire_date']+$changed_date;

$query5="update members set price='£20',exspire_date=$exspire_new where id=2";   

$result5=mysql_query($query5);



}elseif($months==5){

$m=date("m")+5;

$date_know=date("d-$m-y");

$changed_date=strtotime($date_know);

$exspire_new=$payment_months['exspire_date']+$changed_date;

$query6="update members set price='£25',exspire_date=$exspire_new where id=2";   

$result6=mysql_query($query6);

}
  }

?>




<table align="center" bordercolor="black" border="4">

<td align="center">

<form method="POST" action"">

<br>

<font color="red"><b>Each month cost £5 please tell us <br> how mwny months you want to subcribe for.</b></font>

<br>

<select name="payment_months">


<option value="1">1 month</option>

<option value="2">2 month</option>

<option value="3">3 month</option>

<option value="4">4 month</option>

<option value="5">5 month</option>

</select>

<input type="hidden" name="exspire_date">

<input type="hidden" name="id">

<br>
<br>
<br>

<input type="submit" name="submit" value="send">

</form>

</td>

</table>
[/code]

Share this post


Link to post
Share on other sites
redarrow, this forum is for people who need help, hence the name 'PHP Help'. If you wan't to submit a script, you can do it here: http://www.phpfreaks.com/scripts.php?action=addScript

If you still wan't it on the forums, I think [url=http://www.phpfreaks.com/forums/index.php/board,21.0.html]PHP General[/url] would be more appropriate.

Share this post


Link to post
Share on other sites
You could also change your [code=php:0] if ($months ==1) [/code]to

[code]
<?php

switch ($months) {
  case 1:
      // Do stuff here
      break;
  case 2:
      // Do other stuff here
      break;
}
?>
[/code]

Share this post


Link to post
Share on other sites

×

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.