Hint to write code like this

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sonata
Forum Newbie
Posts: 12
Joined: Thu Jan 20, 2011 1:40 am

Hint to write code like this

Post by sonata »

hi
I just need some hint to write code like this book a ride code in this site: http://www.execucar.com/ using php and paypal for payment.

regards
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Hint to write code like this

Post by twinedev »

I think you will have more luck if you give more background. Do you know PHP at all? Have you integrated pay pal before, have you worked with databases before?

I'm not trying to be mean, but you need to be realistic, you are asking for some "hint" to write a program that will do something that we cannot completely know what it does without paying for its service. It is going to just be out of the scope of things people may be willing to do for free on a forum (don't get me wrong, I have spent a few hours of my time helping others before),

Try to break it down to more what you need help with to start.
sonata
Forum Newbie
Posts: 12
Joined: Thu Jan 20, 2011 1:40 am

Re: Hint to write code like this

Post by sonata »

Hi, Thank you twinedev, yes you are right.
I am php beginner, Yes I have good experience with databases, I didn't integrated pay pal before.
I am not asking for complete code here, but I am asking about steps to do that.

regards
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Hint to write code like this

Post by twinedev »

Start at the planning stages. Make lists of things such as:

What all information will you request of the clients, what parts of it will be required, which parts need to validate further (ie, on that page, I told it I wanted a ride to Orlando, but then gave it a zip code in Ohio, so it had to check that.

Also, what data will you need from providers? Pricing, availability, service locations, etc.

Once you get these, start setting up the database, get some good sample test data in there, then start writing a form to collect everything,

That would be a good start, remember, the more time you put into planning it to begin with, the less time you are re-writing things later on. (Believe me, I have suffered from that many times before)

-Greg
sonata
Forum Newbie
Posts: 12
Joined: Thu Jan 20, 2011 1:40 am

Re: Hint to write code like this

Post by sonata »

Thank you so much Greg,
I agree you that more time i put into planning the less time re-writing things later on.
I am sure the coding and passing form to another form is difficult for me but other thing is the payment method and handling the credit card, could you please let me know more about this process, I am planning to use pay pal, do you have any code doing that to integrate it in my planning and coding.

Regards
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Hint to write code like this

Post by califdon »

PayPal can be anything from simple to very complex, depending on what you want to do. Your best resources are at:
https://www.paypal-community.com/t5/US- ... ty/ct-p/US
sonata
Forum Newbie
Posts: 12
Joined: Thu Jan 20, 2011 1:40 am

Re: Hint to write code like this

Post by sonata »

Hi,
Thank you for the link its very useful.
I started creating the database so far I have these tables in database
booking
client
flight
price
I designed the forms to get data from the user and store it in the database.
I have problem using multipages form in php, and how to let the user enter the zip code and then check the price table in Mysql database if the zip code is exist then get the price from the table.

Regards
sonata
Forum Newbie
Posts: 12
Joined: Thu Jan 20, 2011 1:40 am

Re: Hint to write code like this

Post by sonata »

This my first form

Code: Select all

<td width="315" valign="top"><form id="booking" name="booking" method="get" action="zip.php">
          <div class="formContent">
            <p align="center"><strong>Book a Ride</strong></p>
            <p><strong>Select Trip Type:</strong><br />
                <select name="triptype" id="triptype" class="dropDown">
                  <option selected="selected" value="--- Please Select ---">--- Please Select ---</option>
                  <option value="T">To Airport - oneway</option>
                  <option value="F">From Airport - oneway</option>
                </select>
                <br />
            </p>
          </div>
          <div class="formContent"> <strong> <span id="lblAirport" style="font-weight:bold;">Airport:</span></strong><br />
              <select name="airport" id="ddlAirport" class="dropDown">
                <option selected="selected" value="~">--- Please Select ---</option>
                <option value="DAL">Dallas Love Field - (DAL)</option>
                <option value="DFW">Dallas-Ft Worth DFW Airport - (DFW)</option>
              </select>
              <div class="clear"></div>
          </div>
          <div class="formContent">
            <div><strong style="font-size: 11px;"> <span id="lblAddressType" style="font-weight:bold;">Address Type:</span></strong></div>
            <div>
              <select name="address" id="address" class="dropDown">
                <option selected="selected" value="0">--- Please Select ---</option>
                <option value="M">Hotel / Popular Landmark</option>
                <option value="R">Residence / Business</option>
              </select>
            </div>
            <div class="clear"></div>
          </div>
          <div class="formContent">
            <div class="divLeftAdult"> <strong style="font-size: 11px;"> <span id="lblAdult" style="font-weight:bold;">Adult:</span></strong> &nbsp;
                <select name="adult" id="adult" style="width:42px;">
                  <option selected="selected" value="1">1</option>
                  <option value="2">2</option>
                  <option value="3">3</option>
                  <option value="4">4</option>
                  <option value="5">5</option>
                  <option value="6">6</option>
                  <option value="7">7</option>
                  <option value="8">8</option>
                  <option value="9">9</option>
                  <option value="10">10</option>
                  <option value="11">11</option>
                  <option value="12">12</option>
                  <option value="13">13</option>
                  <option value="14">14</option>
                  <option value="15">15</option>
                </select>
            </div>
            <div class="divRightChild"> <strong style="font-size: 11px;"> <span id="lblChild" style="font-weight:bold;">Child (Under 3):</span></strong>&nbsp;
                <select name="children" id="child" style="width:50px;">
                  <option selected="selected" value="0">0</option>
                  <option value="1">1</option>
                  <option value="2">2</option>
                  <option value="3">3</option>
                  <option value="4">4</option>
                  <option value="5">5</option>
                  <option value="6">6</option>
                  <option value="7">7</option>
                  <option value="8">8</option>
                  <option value="9">9</option>
                </select>
                <label>
                <input type="submit" name="button" id="button" value="Submit" />
                </label>
            </div>
          </div>
                </form>
when clicking the submit it should pass all the data to zip.php then the user should enter zipcode then I need to check the database and pass all the information to passenger.php page. and so on.

hear is zip.php page

Code: Select all

<form id="form1" name="form1" method="post" action="">
  <p>Residence / Business Search</p>
  <p><span class="msgFont">Enter zip code, then click Search</span></p>
  <label>
  <input type="text" name="textfield" id="textfield" />
  <br />
  Search
  <input type="submit" name="button" id="button" value="Search" />
  </label>
</form>
sonata
Forum Newbie
Posts: 12
Joined: Thu Jan 20, 2011 1:40 am

Re: Hint to write code like this

Post by sonata »

hi,
I am still need help in this issue.
I am using session to pass data from one form to another form (Multi page form). the next page I need the user to select the zip code from drop down list, I need to check his selection with the my table in the database based on the selection and variable stored in session, so far I have this code:

Code: Select all

$resultid=mysql_query("SELECT zipcode,airport,price FROM price WHERE zipcode='$zipcode' AND airport != ' " .$_SESSION['airport'] ."' ; ", $linkid);
but it did not work it still give me all the airport, it should show only price and airport selected in the first page.

could you help please
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Hint to write code like this

Post by califdon »

sonata wrote:

Code: Select all

$resultid=mysql_query("SELECT zipcode,airport,price FROM price WHERE zipcode='$zipcode' AND airport != ' " .$_SESSION['airport'] ."' ; ", $linkid);
but it did not work it still give me all the airport, it should show only price and airport selected in the first page.
Did you really mean to use != ? That means "not equal". So of course it will return ALL the airports EXCEPT the one from your session variable.
sonata
Forum Newbie
Posts: 12
Joined: Thu Jan 20, 2011 1:40 am

Re: Hint to write code like this

Post by sonata »

Thank you califdon
I need to use equal == but it didn't work for me I am getting this error
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in
when I used this code:

Code: Select all

$resultid=mysql_query("SELECT zipcode,airport,price FROM price WHERE zipcode='$zipcode' AND airport == ' " .$_SESSION['airport'] ."' ; ", $linkid);
I am really stacked in this phase and I can't go forward in this website.

Regards
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Hint to write code like this

Post by califdon »

You just need to study the syntax of SQL, which is not the same as PHP. In SQL there is no such operator as ==, it's simply =. It might seem like it would be wonderful if all the computer languages adhered to the same standard, but there are all sorts of reasons that wouldn't be such a good idea, either.
Post Reply