Ticket Generator

Discussion in 'PHP' started by MrStitch, Jul 25, 2007.

  1. #1
    I have a thread here that I haven't gotten a solid solution for yet.

    Hoping someone would be kind enough to help a brutha out.

    Thanks in advance.....
     
    MrStitch, Jul 25, 2007 IP
  2. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #2
    http://forums.digitalpoint.com/showpost.php?p=3759926&postcount=5

    Seems like it is your best bet.

    action="#" you had a problem with it not doing anything. You have to set the action in the form for it to submit to a page. Also, it would be best if you load this in a page by itself. Also, in the for/next portion of the code I suggest you have it build up a table and place more then one ticket in rows/cols..


    .
     
    exodus, Jul 25, 2007 IP
  3. MrStitch

    MrStitch Peon

    Messages:
    155
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hmmm....

    This will definitely need a lot of 'love' to make work, since I don't know what I'm doing.

    K, first of all, are you suggesting that I make a separate html file that can be written too? If so, I assume I make a table, and add all kinds of cells and divs to line everything up correctly.

    I'm pretty good with html, but know just a teeny bit on forms.

    The 'action' attribute: Do I just put in there http: // www . mysite .com/ticket-page.htm

    ticket-page.htm would be the page that the user generates. OR - Would I want the action to have the page that physically holds the form (all this code that we're talking about) - http: // www . mysite .com/make-your-tickets-here.htm

    Certainly, people here are just rolling their eyes at my inept coding abilities. :(
     
    MrStitch, Jul 25, 2007 IP
  4. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #4
    No one is rolling there eyes. Just we would like to guide you rather then do it for you. ;)

    What you can do is create a table the size you want it to be without your logo, etc. and repeat the tickets in each table cell. (You said you know html) Then use the code that was previded to and just add <?php echo $business; ?> to each of the tickets manually created.

    
    <?php
    if(!isset($_POST['submit'])){
    ////////// THIS IS YOUR FORM
    ?>
    <form action="ticket-page.php" method="POST">
    Business Name: <input type="text" name="name"><br>
    Number of Tickets: <input type="text" name="num"><br>
    <input type="submit" name="submit" value="Generate">
    </form>
    <?php
    ////// Your form ended   
    } else {
        $business = $_POST['name'];
    
    
       echo "<table border='1' cellpadding='0' cellspacing='0'>
               <tr>";
    
    //6 col X 5 rows
    for($count = 0; $count <= $_POST['num']; $count++)
    {
      echo "
    <td>
      <b>".$business."</b>
      <br><br>
      Name:_______________<br>
      Phone:_______________<br>
      Address:_______________
    </td>";
      if($xxx = 5) { echo "</tr><tr>"; $xxx = 0; }
      $xxx++;
    }
      echo "</tr></table>";
       //This ends the ticket HTML
        }
    ?>
    
    PHP:
     
    exodus, Jul 25, 2007 IP
  5. MrStitch

    MrStitch Peon

    Messages:
    155
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Uhg.... K, here's what I've got so far.....

    I've created two separate files. One is the ticket generator and the other is the tickets page.

    The tickets-page is in php format and has a table, 2 columns wide by 5 rows high, for a total of ten tickets.

    In each cell, I've placed this code -

    <b><?PHP echo $business; ?></b><br><br>
      Name:_______________<br>
      Phone:_______________<br>
      Address:_______________
    Code (markup):
    I'm guessing thats all I need, since all I want to do is copy the business name from the form, into each cell.

    Next, I have the main ticket generator, saved as a php file, and this code is in the body....

    <?php
    if(!isset($_POST['submit'])){
    ////////// THIS IS YOUR FORM
    ?>
    <form action="http://www.mysite.com/tickets-page.php" method="POST" name="tickets">
    Business Name: <input type="text" name="name"><br>
    Number of Tickets: <input type="text" name="num"><br> 
    <input type="submit" name="submit" value="Generate">
    </form>
    <?php
    ////// Your form ended    
    } else {
        $business = $_POST['name'];
        for($i=0;$i<$_POST['num'];$i++){
        // this is the HTML for each ticket
    ?>
    Code (markup):
    Granted - At this point, I think the 'Number of Tickets' part in the form is fairly irrelevant, as the user will generate a single pages' worth of tickets, and then just print the individual page. They'll tell their printer how many copies they want. So we could just wipe that part out anyways.... would like nicer centered on screen also, with just the business name box, only.

    Now, I've uploaded the two files to my server, and tried it out. As luck would have it, the page wouldn't load and all I got was this....

    "Parse error: syntax error, unexpected $end in /home/domain/public_html/ticket-maker.php on line 62"


    I fiddled around with the code for a bit, copy, paste, copy, paste, delete, etc.... still get the same message. I completely removed the php code, and then the page loaded fine, without the form of course.

    As a side note, I have a contact page that is in php, and it's worked fine from day one... still does. So I wouldn't think it's a server problem.

    Do I need special code up in the head area that makes the browser read it properly? All that code there is just in the body, nothing up top.

    And what the heck is a Parse Error? hahahahha
     
    MrStitch, Jul 26, 2007 IP