Do I need to use classes?

This is a discussion on Do I need to use classes? within the PHP Language forums, part of the PHP Programming Forums category; Hi again folks, As a relative newbie I am probably trying to run before I can walk but here goes: ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-12-2004
Dynamo
 
Posts: n/a
Default Do I need to use classes?

Hi again folks,
As a relative newbie I am probably trying to run before I can walk but here
goes:

Thanks to all you good folks I have managed to get some sort of a site up and
running whereby people can view my catalogue, select items from it and then send
the aggregate amount to PayPal for payment processing. I have a precheckout page
where people can view their selected items before proceeding to the final
payment stage. My script is as follows:

$query = 'SELECT * FROM Catalogue WHERE id IN (' . implode( ',',
$_POST['selection'] ) . ')';
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());
$totalprice = 0;
echo "<table cellpadding=2 border=0>";

echo "<tr>";
echo "<td bgcolor='#FF8000' valign='top' align='center'><font face='Arial'
size='1'><u><b>Cat No</b></u></font></td>";
echo "<td bgcolor='#FF8000' valign='top' align='center'><font face='Arial'
size='1'><u><b>Description</b></u></font></td>";
echo "<td bgcolor='#FF8000' valign='top' align='center'><font face='Arial'
size='1'><u><b>Price</b></u></font></td>";
echo "</tr>";

while($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td><font face='Arial' size='1'>" . $row[0] . "</font></td>";
echo "<td><font face='Arial' size='1'>" . $row[3] . "</font></td>";
echo "<td><font face='Arial' size='1'>£" . $row[6] . "</font></td>";
echo "</tr>";
$totalprice += $row[6];
}
echo "</table>";
echo "<p align='center'><b><font color='#FF0000'>Total price of selected items =
£$totalprice</br>Your credit card will be debited with this
amount</br></font></b></p>";
echo "<form action='https://www.paypal.com/cgi-bin/webscr' method='post'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='business' value='myemailaddress'>
<input type='hidden' name='item_name' value='aggregatepurchase'>
<input type='hidden' name='currency_code' value='GBP'>
<input type='hidden' name='amount' value='$totalprice'>
<p align='center'><b>Payment method is via PayPal - The secure way to make
payments over the internet.</b></p>
<p align='center'><input type='image' src='x-click-but03.gif' name='submit'
alt='Make payments with PayPal - it's fast, free and secure!'></p>
</form>";

Yeah Yeah I know it needs tidying but it works.
My question is will it work in the real world. What happens if their are
multiple users all trying to checkout at the same time and trying to access the
same checkout script? Do I need to use classes?

Any help/suggestions greatly appreciated.

Regards
Dynamo

Reply With Quote
  #2 (permalink)  
Old 12-13-2004
thelobster@gmail.com
 
Posts: n/a
Default Re: Do I need to use classes?


Dynamo wrote:
> Hi again folks,
> As a relative newbie I am probably trying to run before I can walk

but here
> goes:
>
> Thanks to all you good folks I have managed to get some sort of a

site up and
> running whereby people can view my catalogue, select items from it

and then send
> the aggregate amount to PayPal for payment processing. I have a

precheckout page
> where people can view their selected items before proceeding to the

final
> payment stage. My script is as follows:
>
> $query = 'SELECT * FROM Catalogue WHERE id IN (' . implode( ',',
> $_POST['selection'] ) . ')';
> $result = mysql_query($query) or die ("Error in query: $query. " .
> mysql_error());
> $totalprice = 0;
> echo "<table cellpadding=2 border=0>";
>
> echo "<tr>";
> echo "<td bgcolor='#FF8000' valign='top' align='center'><font

face='Arial'
> size='1'><u><b>Cat No</b></u></font></td>";
> echo "<td bgcolor='#FF8000' valign='top' align='center'><font

face='Arial'
> size='1'><u><b>Description</b></u></font></td>";
> echo "<td bgcolor='#FF8000' valign='top' align='center'><font

face='Arial'
> size='1'><u><b>Price</b></u></font></td>";
> echo "</tr>";
>
> while($row = mysql_fetch_row($result)) {
> echo "<tr>";
> echo "<td><font face='Arial' size='1'>" . $row[0] .

"</font></td>";
> echo "<td><font face='Arial' size='1'>" . $row[3] .

"</font></td>";
> echo "<td><font face='Arial' size='1'>£" . $row[6] .

"</font></td>";
> echo "</tr>";
> $totalprice += $row[6];
> }
> echo "</table>";
> echo "<p align='center'><b><font color='#FF0000'>Total price of

selected items =
> £$totalprice</br>Your credit card will be debited with this
> amount</br></font></b></p>";
> echo "<form action='https://www.paypal.com/cgi-bin/webscr'

method='post'>
> <input type='hidden' name='cmd' value='_xclick'>
> <input type='hidden' name='business'

value='myemailaddress'>
> <input type='hidden' name='item_name'

value='aggregatepurchase'>
> <input type='hidden' name='currency_code' value='GBP'>
> <input type='hidden' name='amount' value='$totalprice'>
> <p align='center'><b>Payment method is via PayPal - The secure way to

make
> payments over the internet.</b></p>
> <p align='center'><input type='image' src='x-click-but03.gif'

name='submit'
> alt='Make payments with PayPal - it's fast, free and secure!'></p>
> </form>";
>
> Yeah Yeah I know it needs tidying but it works.
> My question is will it work in the real world. What happens if their

are
> multiple users all trying to checkout at the same time and trying to

access the
> same checkout script? Do I need to use classes?
>
> Any help/suggestions greatly appreciated.
>
> Regards
> Dynamo


Reply With Quote
  #3 (permalink)  
Old 12-13-2004
thelobster@gmail.com
 
Posts: n/a
Default Re: Do I need to use classes?

It does not look like you need to use a class, although it may make
things neater and nicer to deal with. There shoulden't be a PHP problem
if you have a mass of requests to the page so long as the SQL server
and web server are functioning properly and can handle the number of
requests.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:33 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0