Need Help With Classified Ad Script Adding To Php

Discussion in 'PHP' started by fitzwar, Jul 17, 2009.

  1. #1
    Hi,

    I currently have a classified ads turnkey script and adult personal script that are both programed the same. What i need to do is add a payment plan that allows the user to post an item for free. The problem i get is if i set up a payment plan within the control panel for 0.00 and when the user selects this price plan they are still taken to paypal to pay.

    Is there a way to add some code to the php files to set up a free payment plan

    Here are my configuration files:

    Contents of Payment.php
    <?
    require_once("conn.php");
    require_once("includes.php");

    if(empty($_GET[SelectedPackage]))
    {
    header("location:$_SERVER[HTTP_REFERER]?e=1&PaymentGateway=$_GET[PaymentGateway]");
    }
    elseif(empty($_GET[PaymentGateway]))
    {
    header("location:$_SERVER[HTTP_REFERER]?e=2&SelectedPackage=$_GET[SelectedPackage]");
    }
    else
    {
    if(!empty($_SESSION[AgentID]))
    {
    $MyID = $_SESSION[AgentID];
    }

    if(!empty($_SESSION[MemberID]))
    {
    $MyID = $_SESSION[MemberID];
    }

    //get the agent details
    $q1 = "select * from personal_members where MemberID = '$MyID' ";
    $r1 = mysql_query($q1) or die(mysql_error());
    $a1 = mysql_fetch_array($r1);

    //get the price details
    $q2 = "select * from personal_prices where PriceID = '$_GET[SelectedPackage]' ";
    $r2 = mysql_query($q2) or die(mysql_error());
    $a2 = mysql_fetch_array($r2);

    /*

    flags:

    r -> renew

    n -> new

    m -> more

    */

    if(ereg("renew.php", $_SERVER[HTTP_REFERER]))
    {
    $flag = "r";
    $action = "Renewal";
    }
    elseif(ereg("more.php", $_SERVER[HTTP_REFERER]))
    {
    $flag = "m";
    $action = "Upgrade";
    }
    else
    {
    $flag = "n";
    $action = "Activation";
    }

    if($_GET[PaymentGateway] == "paypal")
    {
    header("location:https://www.paypal.com/xclick?business=$aset[PayPalEmail]&item_name=$a2[ads] ads for $a2[days] days&first_name=$a1[FirstName]&last_name=$a1[LastName]&email=$a1&item_number=1&custom=$MyID|$_GET[SelectedPackage]|$flag&amount=$a2[price]&currency_code=GBP&notify_url=http://$_SERVER[HTTP_HOST]$dir/notify.php&return=http://$_SERVER[HTTP_HOST]$dir/login.php");

    exit();

    }
    else
    {
    //manual

    //send an email to the admin
    $to = $aset[ContactEmail];
    $subject = "Manual Service $action Request";
    $message = "A client has selected Manual Service $action\nHere are the details:\n\n";
    $message .= "Username: $a1[username]\nNames: $a1[FirstName] $a1[LastName]\nSelected Package: $a2[ads] ";

    if($a2[PriorityLevel] == '1')
    {
    $message .= "Featured ";
    }

    $message .= "ads for $a2[days] days\nPrice: £$a2[price]\n";


    $headers = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
    $headers .= "Content-Transfer-Encoding: 8bit\n";
    $headers .= "From: WebSites <$aset[ContactEmail]>\n";
    $headers .= "X-Priority: 1\n";
    $headers .= "X-MSMail-Priority: High\n";
    $headers .= "X-Mailer: PHP/" . phpversion()."\n";

    mail($to, $subject, $message, $headers);

    //send an email to the client

    $to = $a1[email];
    $subject = "Your registration at $_SERVER[HTTP_HOST]";
    $message = "Hello $a1[FirstName] $a1[LastName],\nhere is your login information for $_SERVER[HTTP_HOST]\n\nUsername: $a1[username]\nPassword: $a1[password]\n\nWe will send you another email message, when your account is activated.\n\nThank you for your registration!";

    $headers = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
    $headers .= "Content-Transfer-Encoding: 8bit\n";
    $headers .= "From: $_SERVER[HTTP_HOST] <$aset[ContactEmail]>\n";
    $headers .= "X-Priority: 1\n";
    $headers .= "X-MSMail-Priority: High\n";
    $headers .= "X-Mailer: PHP/" . phpversion()."\n";

    mail($to, $subject, $message, $headers);

    //get the templates
    require_once("templates/HeaderTemplate.php");
    require_once("templates/ManualTemplate.php");
    require_once("templates/FooterTemplate.php");
    }

    }

    ?>


    [B]Contents of Prices.php[/B]

    <?
    require_once("conn.php");
    require_once("includes.php");

    //get the prices
    $q1 = "select * from personal_prices order by PriorityLevel desc, ads, days";
    $r1 = mysql_query($q1) or die(mysql_error());

    $col = "white";

    while($a1 = mysql_fetch_array($r1))
    {
    if($col == "white")
    {
    $col = "dddddd";
    }
    else
    {
    $col = "white";
    }

    $Prices .= "<tr bgcolor=$col>\n\t<td align=center>";

    if($_GET[SelectedPackage] == $a1[PriceID])
    {
    $Prices .= "<input type=radio name=\"SelectedPackage\" value=\"$a1[PriceID]\" checked>";
    }
    else
    {
    $Prices .= "<input type=radio name=\"SelectedPackage\" value=\"$a1[PriceID]\">";
    }

    if($a1[ads] > '1')
    {
    $s = "s";
    }
    else
    {
    $s = "";
    }

    $Prices .= "</td>\n\t<td>$a1[ads] ad$s for $a1[days] days";

    if($a1[PriorityLevel] == '1')
    {
    $Prices .= " <sup><font color=\"#990000\" face=verdana size=2><b>Featured</b></font></sup>";
    }

    $Prices .= "</td>\n\t";

    $Prices .= "<td align=right>£$a1[price]</td>\n</tr>\n";
    }

    if($_GET[e] == '1')
    {
    $error = "Select a package, please!";
    }
    elseif($_GET[e] == '2')
    {
    $error = "Select a payment method, please!";
    }

    if($_GET[PaymentGateway] == "paypal")
    {
    $selected1 = "selected";
    }
    elseif($_GET[PaymentGateway] == "2checkout")
    {
    $selected2 = "selected";
    }


    //get the templates
    require_once("templates/HeaderTemplate.php");
    require_once("templates/PricesTemplate.php");
    require_once("templates/FooterTemplate.php");

    ?>



    [B]Contents of More.php[/B]

    <?
    require_once("conn.php");
    require_once("includes.php");

    if($_GET[st] == "1")
    {
    $added = "<font face=verdana size=2 color=black><b>Your asset has been added successfully!</b></font>";
    }

    //get the prices
    $q1 = "select * from personal_prices order by PriorityLevel desc, ads, days";
    $r1 = mysql_query($q1) or die(mysql_error());

    $col = "white";

    while($a1 = mysql_fetch_array($r1))
    {
    if($col == "white")
    {
    $col = "dddddd";
    }
    else
    {
    $col = "white";
    }

    $Prices .= "<tr bgcolor=$col>\n\t<td align=center>";

    if($_GET[SelectedPackage] == $a1[PriceID])
    {
    $Prices .= "<input type=radio name=\"SelectedPackage\" value=\"$a1[PriceID]\" checked>";
    }
    else
    {
    $Prices .= "<input type=radio name=\"SelectedPackage\" value=\"$a1[PriceID]\">";
    }


    $Prices .= "</td>\n\t<td>$a1[ads] ads for $a1[days] days";

    if($a1[PriorityLevel] == '1')
    {
    $Prices .= " <sup><font color=\"#990000\" face=verdana size=2><b>Featured</b></font></sup>";
    }

    $Prices .= "</td>\n\t";

    $Prices .= "<td align=right>$$a1[price]</td>\n</tr>\n";
    }

    if($_GET[e] == '1')
    {
    $error = "Select a package, please!";
    }
    elseif($_GET[e] == '2')
    {
    $error = "Select a payment method, please!";
    }

    if($_GET[PaymentGateway] == "paypal")
    {
    $selected1 = "selected";
    }
    elseif($_GET[PaymentGateway] == "2checkout")
    {
    $selected2 = "selected";
    }
    elseif($_GET[PaymentGateway] == "check")
    {
    $selected3 = "selected";
    }

    //get the templates
    require_once("templates/HeaderTemplate.php");
    require_once("templates/MoreTemplate.php");
    require_once("templates/FooterTemplate.php");

    ?>


    Here is a link to my site which is running the script that i need to add this free option plan

    http://www.websitesforsaleworld.co.uk/Demos/Classified/index.php


    I would be grateful for any ideas that any of you professionals may have ?
     
    fitzwar, Jul 17, 2009 IP
  2. fitzwar

    fitzwar Well-Known Member

    Messages:
    369
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    118
    #2
    Im willing to pay $25 if someone knows the answer and if it works?
     
    fitzwar, Jul 18, 2009 IP
  3. Goramba

    Goramba Peon

    Messages:
    128
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It's a lot to look through and I can't be sure without testing, but try changing:

    if($_GET[PaymentGateway] == "paypal")
    PHP:
    TO

    if($_GET[PaymentGateway] == "paypal" && $a2[price] > 0)
    PHP:
     
    Goramba, Jul 18, 2009 IP
  4. fitzwar

    fitzwar Well-Known Member

    Messages:
    369
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    118
    #4
    Thanks do i add just add the follwoing line to the prices.php if so where is the best place for it?

    if($_GET[PaymentGateway] == "paypal" && $a2[price] > 0)
     
    fitzwar, Jul 18, 2009 IP