www.webdeveloper.com
Results 1 to 6 of 6

Thread: multiple pages in one file

  1. #1
    Join Date
    May 2003
    Location
    Millis, MA
    Posts
    453

    multiple pages in one file

    I was wondering if it is possible to hold several e-mail pages in one PHP file and use PHP to determine which page to display based on a variable or hidden input on the parent page. This is what I've got so far:

    PHP Code:
    <title>send stuff!</title>
    <link rel="STYLESHEET" type="text/css" href="../popups/popup.css">
    <font color=#F0F0F0>
    <form action="mailthing.php" method="post">
    <?php

      
    if ($opinion) {
      echo(
    '
    ?>
    <center>Hey, it'
    s e-mail time!</center>
    <
    br><br><br><br>
    Which topic are you responding to?
    <
    form action="mailthing.php" method="post">
    <
    select name="subject">
    <
    option value="response:society">Society
    <option value="response:religion">Religion
    </select>
    <
    br><br>
    Enter your opinions:
    <
    br>
    <
    textarea name="message" rows=10 cols=50></textarea>
    <
    br><br>
    <
    input type="submit" name="submit" value="I'm in for it, aren't I...">
    <
    input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
    </
    form>
    <?
    ');
    } elseif ($comment) {
      echo('
    ?>
    <br><br>
    <center>Tell me whatchu think!</center>
    <br><br>
    <form action="mailthing.php" method="post">
    <textarea rows=10 cols=50>Any ideas? Suggestions? Send 'em to me!</textarea>
    <br><br>
    <input type="submit" name="submit" value="lemme hear it...">
    <input type="hidden" name="subject" value="comments">
    <input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
    </form>
    <?
    ');
    } elseif ($random) {
      echo('
    ?>
    <br><br>
    <center>Randomness!</center>
    <br><br>
    Got a funny or bizarre quote?  A strange story?  An annoying habit of submitting stuff whenever you get the opportunity?  Your search is over!  Send it to me!
    <br><br>
    <form action="mailthing.php" method="post">
    <textarea rows=10 cols=50>Tell me, tell me, tell me!</textarea>
    <br><br>
    <input type="submit" name="submit" value="well...">
    <input type="hidden" name="subject" value="random">
    <input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
    </form>
    <?
    ');
    } else {
      echo('
    ?>
    <br><br>
    <center>EMAIL APP</center>
    <br><br>
    <center>
    To:<input type="text" name="mailto" length=15>
    <br>
    Subject:<input type="text" name="subject" length=10>
    <br>
    Message:<textarea rows=10 cols=50></textarea>
    <br><br>
    <input type="submit" name="submit" value="SEND EMAIL">
    <br><br>
    </form>
    <?
    ');
    }
    ?>
    Any help is appreciated.
    isn't this profound...
    http://www.radioactiverabbit.com

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    This page shows a variation of that: http://www.infinitypages.com/research/divinclude.php. It basically sends a query string to the browser telling it which page to display. Could easily be modefied to just show certain parts of a page based on the query string.

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  3. #3
    Join Date
    May 2003
    Location
    Millis, MA
    Posts
    453
    I tried your suggestion, but I can't figure it out. I'm probably missing something obvious, but I just can't get it to work.
    This is what I have so far:

    PHP Code:
    <?php
    if ($_SERVER["QUERY_STRING"] == "")
    {
        
    $include "email/mailapp.php";
    }
    else
    {
        
    $include $_SERVER["QUERY_STRING"];
    }
    include(
    "$include");
    ?>
    <title>send stuff!</title>
    <link rel="STYLESHEET" type="text/css" href="../popups/popup.css">
    <font color=#F0F0F0>
    <?php
      $opinion 
    = echo('
    ?>
    <center>Hey, it'
    s e-mail time!</center>
    <
    br><br><br><br>
    Which topic are you responding to?
    <
    form action="mailthing.php" method="post">
    <
    select name="subject">
    <
    option value="response:society">Society
    <option value="response:religion">Religion
    </select>
    <
    br><br>
    Enter your opinions:
    <
    br>
    <
    textarea name="message" rows=10 cols=50></textarea>
    <
    br><br>
    <
    input type="submit" name="submit" value="I'm in for it, aren't I...">
    <
    input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
    </
    form>
    <?
    ');
      $comment = echo('
    ?>
    <br><br>
    <center>Tell me whatchu think!</center>
    <br><br>
    <form action="mailthing.php" method="post">
    <textarea rows=10 cols=50>Any ideas? Suggestions? Send 'em to me!</textarea>
    <br><br>
    <input type="submit" name="submit" value="lemme hear it...">
    <input type="hidden" name="subject" value="comments">
    <input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
    </form>
    <?
    ');
      $random = echo('
    ?>
    <br><br>
    <center>Randomness!</center>
    <br><br>
    Got a funny or bizarre quote?  A strange story?  An annoying habit of submitting stuff whenever you get the opportunity?  Your search is over!  Send it to me!
    <br><br>
    <form action="mailthing.php" method="post">
    <textarea rows=10 cols=50>Tell me, tell me, tell me!</textarea>
    <br><br>
    <input type="submit" name="submit" value="well...">
    <input type="hidden" name="subject" value="random">
    <input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
    </form>
    <?
    ');
      $mailapp = echo('
    ?>
    <br><br>
    <center>EMAIL APP</center>
    <br><br>
    <form action="mailthing.php" method="post">
    <center>
    To:<input type="text" name="mailto" length=15>
    <br>
    Subject:<input type="text" name="subject" length=10>
    <br>
    Message:<textarea rows=10 cols=50></textarea>
    <br><br>
    <input type="submit" name="submit" value="SEND EMAIL">
    <br><br>
    </form>
    <?
    ');
    }
    ?>
    Thanks!
    isn't this profound...
    http://www.radioactiverabbit.com

  4. #4
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Ok, how about we use your original code? Shouldn't be too hard to get working. Just tell me when/under what circumstances the certain parts of the pages should be displayed, and I'll show you how to do it.

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  5. #5
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Ok, I think maybe I know what you're trying to do... The main problem with your code is the echo statements. When you are moving in and out of PHP like you are, you don't use echo. The only other thing I changed was the way it calls the variables. I wrote it so it will work when global variables are turned off.

    take a look at this code:

    PHP Code:
    <title>send stuff!</title>
    <link rel="STYLESHEET" type="text/css" href="../popups/popup.css">
    <font color=#F0F0F0>

    <form action="mailthing.php" method="post">

    <?php
    if ($_GET['opinion']) {
        
    ?>
        <center>Hey, it's e-mail time!</center>
        <br><br><br><br>
        Which topic are you responding to?
        <form action="mailthing.php" method="post">
        <select name="subject">
        <option value="response:society">Society
        <option value="response:religion">Religion
        </select>
        <br><br>
        Enter your opinions:
        <br>
        <textarea name="message" rows=10 cols=50></textarea>
        <br><br>
        <input type="submit" name="submit" value="I'm in for it, aren't I...">
        <input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
        </form>
        <?
    }
    else if (
    $_GET['comment']) {
        
    ?>
        <br><br>
        <center>Tell me whatchu think!</center>
        <br><br>
        <form action="mailthing.php" method="post">
        <textarea rows=10 cols=50>Any ideas? Suggestions? Send 'em to me!</textarea>
        <br><br>
        <input type="submit" name="submit" value="lemme hear it...">
        <input type="hidden" name="subject" value="comments">
        <input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
        </form>
        <?

    else if (
    $_GET['random']) {
        
    ?>
        <br><br>
        <center>Randomness!</center>
        <br><br>
        Got a funny or bizarre quote?  A strange story?  An annoying habit of submitting stuff whenever you get the opportunity?  Your search is over!  Send it to me!
        <br><br>
        <form action="mailthing.php" method="post">
        <textarea rows=10 cols=50>Tell me, tell me, tell me!</textarea>
        <br><br>
        <input type="submit" name="submit" value="well...">
        <input type="hidden" name="subject" value="random">
        <input type="hidden" name="mailto" value="brandon@radioactiverabbit.com">
        </form>
        <?

    else {
        
    ?>
        <br><br>
        <center>EMAIL APP</center>
        <br><br>
        <center>
        To:<input type="text" name="mailto" length=15>
        <br>
        Subject:<input type="text" name="subject" length=10>
        <br>
        Message:<textarea rows=10 cols=50></textarea>
        <br><br>
        <input type="submit" name="submit" value="SEND EMAIL">
        <br><br>
        </form>
        <?
    }
    ?>
    to show first form, use a query string ?opinion=1 to show the second use a query string ?comments=1, etc

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  6. #6
    Join Date
    May 2003
    Posts
    16
    or a switch...

    PHP Code:
    <?
    switch($_GET["p"]){
    case 
    "comment":
     echo 
    "Comment stuff";
     echo 
    "more comment stuff";
    ?> or you can do this <?
     
    break;
    case 
    "other":
     echo 
    "other stuff";
     echo 
    "more stuff";
     break;
    default:
    echo 
    "oops, not a valid option";
    }
    ?>
    and you would link to

    page.php?p=comment

    or

    page.php?p=other


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