www.webdeveloper.com
Results 1 to 8 of 8

Thread: Fairly Non-Difficult PHP Question...

  1. #1
    Join Date
    Apr 2008
    Posts
    15

    Fairly Non-Difficult PHP Question...

    I have a webform on my Page with that has the ability to upload a File. It also collects a bit of information, including a value for "Platform", a value for "Game", and a value for "Guide Type". When the webform is submitted, it passes it into Moderation to be approved. Once it's approved, it creates a page much like this:

    http://gamesave.me/guide-details.php?id=31

    Or this:

    http://gamesave.me/guide-details.php?id=9

    All I need to do is add something into the <title> tag on "guide-details.php" so that it will display some of the <form> data that was entered. Can someone step me through this?

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    661
    Not without seeing some of the code. It really shouldn't be that hard as you say. Although if you want to "show" some info about the selection of data, wouldn't it be better to make it part of the heading on the page itself since the title area is limited by browser type and window size?

  3. #3
    Join Date
    Apr 2008
    Posts
    15
    I can't just go into "guide-details.php" and change the <title> tag because then it's just going to show that specific wording on every page.

    I need to retrieve the form data to be displayed in the <title> of the webpage because each page is going to have something different when the file is uploaded and approved. This is the <form>

    HTML Code:
    <table width="800">
            
            	<tr>
                	<td width="225">Choose Platform : </td>
                    
                	<td>
                    <select name="plateform" id="plateform" style="margin-bottom:15px; height:30px; width:200px;" onchange="getcat(this.value);" >
                    <option value="">Choose Platform</option>
                    <?php while($data1=mysql_fetch_assoc($rs1)){ ?>
                    <option value="<?php echo $data1['id'];?>"><?php echo $data1['name'];?></option>
                    <?php }?>
                    </select>
                    </td>
                </tr>
                <tr>
                	<td width="225">Choose Category : </td>
                    
                	<td>
                    <select name="category" id="cat123" style="margin-bottom:15px; height:30px; width:200px;" onchange="getgame(this.value);" >
                   
                    <option value="">Select Platform First</option>
                   
                    </select>
                    </td>
                </tr>
                
                
                 <tr>
                	<td width="225">Choose Game :<br />
                	  <a href="/submitgame.php"><em>(Not Listed?)</em></a><em></em></td>
                    
                	<td>
                    <select name="game" id="game123" style="margin-bottom:15px; height:30px; width:200px;" >
                   
                    <option value="">Select Category First</option>
                   
                    </select>
                    </td>
                </tr>
                
                <tr>
                	<td width="225">Guide Type : </td>
                    
                	<td>
                   <input type="text" id="guidetitle" name="guidetitle"  />
                    </td>
                </tr>
                
                
                <tr>
                	<td width="225">Upload Text File : </td>
                    
                	<td>
                   <input type="file" id="filename" name="guide"  />
                    </td>
                </tr>
                
                
                
                <tr>
                	<td width="100">&nbsp;</td>
                	<td><input class="button" name="submit" type="submit" value="Upload"></td>
                </tr>
    			
            </table>

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    661
    I understand what you want to do. I just think that you should do it with a <p> tag at the top of the page instead of in the (as I said) limited <title> area. Doing it is up to you and your php skills.

  5. #5
    Join Date
    Apr 2008
    Posts
    15
    My PHP Skills are pretty basic at best. I'm probably only familiar with a couple of different uses..

    If you look at this Forum for example, when you switch from one page to another, the heading in the <title> tag changes from thread to threat. That's all I'm trying to do, but I'm not sure how to do that...

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,245
    First of all, you have to know where the desired data can be accessed. Will it be in the $_POST (or $_GET) array as submitted by the form, in $_SESSION, or do you have to pull it from the database? If we assume for the moment that it's in $_POST, it could simply be something like:
    PHP Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title><?php
    if(!empty($_POST['some_field_name'])) {
        echo 
    htmlspecialchars($_POST['some_field_name']);
    }
    else {
        echo 
    "Default value if nothing submitted"
    }
    ?></title>
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  7. #7
    Join Date
    Jun 2007
    Posts
    400
    I'm a bit confused, once it passes moderation and all nothing is really coming from the form anymore, is it? Aren't you really looking at how to get that data from wherever it is being stored in the database and putting it into the title?

  8. #8
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    661
    Don't know what your ref to moderation is all about....

    php is simply a tool to (in your case) collect data and paste it into some html in order to format it on a client's screen. You need to locate where the data is being received in the script, learn how to extract the elements of it that you want to write out and then put some html around them and output them at the right moment amidst all the other output being sent. YOU want to do it as a title tag - fine. Just wrap it in the tags and place it. OTOH - I think it will look better as part of a page header since the title area of a window can be limited. In that case you would wrap it in a <p> or h2 or h3 tag and place it at the top of the body element.

    PS - the better way IMO is to do all the data extraction and formatting of it by storing it in a php variable. Then in your display portion of your script place that variable where you want the data to appear. Saves on tags and confusion by not mingling presentation and content prep. Ex. - build the data into a php var named "$my_title_data" and then down where you actually output the title tag simply put "<title><?php $my_title_data ?></title>".

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles