Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 August 2006 - 01:02 PM

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.



<?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>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 15 August 2006 - 03:23 PM

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...ction=addScript

If you still wan't it on the forums, I think PHP General would be more appropriate.

#3 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 15 August 2006 - 04:27 PM

You could also change your
if ($months ==1)
to

<?php

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users