redarrow Posted August 15, 2006 Share Posted August 15, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/17621-my-full-code-for-beginers-to-be-able-to-have-a-paying-login-system/ Share on other sites More sharing options...
Daniel0 Posted August 15, 2006 Share Posted August 15, 2006 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=addScriptIf 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. Quote Link to comment https://forums.phpfreaks.com/topic/17621-my-full-code-for-beginers-to-be-able-to-have-a-paying-login-system/#findComment-75166 Share on other sites More sharing options...
SharkBait Posted August 15, 2006 Share Posted August 15, 2006 You could also change your [code=php:0] if ($months ==1) [/code]to [code]<?phpswitch ($months) { case 1: // Do stuff here break; case 2: // Do other stuff here break;}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/17621-my-full-code-for-beginers-to-be-able-to-have-a-paying-login-system/#findComment-75204 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.