Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post php script for testing html

    this is a php script for testing code like html, not sure why it's not working it's probably something really simple. So the input(left) is a textarea for the html and the output(right) is the display. This should be really simple!?! I add the is echo "<!DOCTYPE html>\n"; after the fact, I really didn't think it was going to make any difference.

    Code:
    <?PHP 
    
    FUNCTION generateFrames(){
    echo "<FRAMESET COLS=\"660,*\">\n";
    echo "<FRAME NAME=\"input\" SRC=\"generate.php?page=left\">\n";
    echo "<FRAME NAME=\"output\" SRC=\"generate.php?page=right\">\n";
    echo "</FRAMESET>";
    }
    
    IF($page=="left"){
    echo "<BODY BGCOLOR=\"#FFFFFF\">";
    echo "<FONT FACE=\"Arial,Verdana,Helvetica\" COLOR=\"FF0000\" SIZE=\"3\">PHP Tester</FONT>";
    echo "<FORM METHOD=\"post\" ACTION=\"generate.php?page=right\" TARGET=\"output\">\n";
    echo "<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">\n";
    echo "<TR><TD><TEXTAREA NAME=\"input\" COLS=\"100\" ROWS=\"40\" WRAP=\"virtual\">".$input."</TEXTAREA></TD></TR>\n";
    echo "<TR><TD ALIGN=\"center\"><INPUT TYPE=\"submit\" VALUE=\"Execute\"></TD></TR></TABLE></FORM>\n";
    echo "</BODY>";
    }
    
    ELSE IF ($page=="right"){
    echo "<BODY BGCOLOR=\"#FFFFFF\">";
    IF(EMPTY($input)) {
    echo "Ready to parse...";
    }
    ELSE {
    $input=STRIPSLASHES($input);
    EVAL($input);
    }
    echo "</BODY>";
    }
    
    ELSE {
    generateFrames();
    
    }
    
    ?>
    Last edited by fulltiltphil; 10-30-2013 at 04:06 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    $page doesn't exist, and these querystrings are no good: generate.php?$page=left. $ does not go into the querystring.
    Pull the page from the $_GET['page'] superglobal. $page using register_globals has been removed as of 5.4, officially deprecated as of 5.3, and unofficially deprecated as of 4.2.0.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Mar 2011
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I didn't originally have the $page in the query I was throwing stones to see if I could get something to work. I'll try the $_GET['page'] .

    Code:
    <?PHP 
    
    $page = isset($_GET['page']) ? (int)$_GET['page'] : 0;
    
    FUNCTION generateFrames() {
    echo "<FRAMESET COLS=\"660,*\">\n";
    echo "<FRAME NAME=\"input\" SRC=\"generate.php?page=left\">\n";
    echo "<FRAME NAME=\"output\" SRC=\"generate.php?page=right\">\n";
    echo "</FRAMESET>";
    }
    
    IF($page=="left") {
    echo "<BODY BGCOLOR=\"#FFFFFF\">";
    echo "<FONT FACE=\"Arial,Verdana,Helvetica\" COLOR=\"FF0000\" SIZE=\"3\">PHP Tester</FONT>";
    echo "<FORM METHOD=\"post\" ACTION=\"generate.php?page=right\" TARGET=\"output\">\n";
    echo "<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">\n";
    echo "<TR><TD><TEXTAREA NAME=\"input\" COLS=\"100\" ROWS=\"40\" WRAP=\"virtual\">".$input."</TEXTAREA></TD></TR>\n";
    echo "<TR><TD ALIGN=\"center\"><INPUT TYPE=\"submit\" VALUE=\"Execute\"></TD></TR></TABLE></FORM>\n";
    echo "</BODY>";
    }
    
    ELSE IF ($page=="right") {
    echo "<BODY BGCOLOR=\"#FFFFFF\">";
    IF(EMPTY($input)) {
    echo "Ready to parse...";
    }
    ELSE {
    $input=STRIPSLASHES($input);
    EVAL($input);
    }
    echo "</BODY>";
    }
    
    ELSE {
    generateFrames();
    
    }
    
    ?>
    Last edited by fulltiltphil; 10-30-2013 at 05:59 PM.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    What if your HTML was stored as a text file (example test1.txt) and you used PHP to 'include' that in your PHP test program? The person uses a basic PHP editor script to make changes to the .txt file and resaves it ... then they test it for real. This would allow you to also let put javascripting along with HTML.

  • #5
    New Coder
    Join Date
    Mar 2011
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this is still not working I'm trying to figure out how to us a $_GET['page'] to get the frame set information for the input and the output. I'm just not getting it?

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    PHP Code:
    $page = isset($_GET['page']) ? (int)$_GET['page'] : 0
    Put that before your read of the $page.
    Note that you'll also need to use $_POST['input'] further down. And whatever you do, don't show the HTML to the HTML guys >.>
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #7
    New Coder
    Join Date
    Oct 2013
    Location
    South Africa
    Posts
    12
    Thanks
    4
    Thanked 0 Times in 0 Posts
    It would be better and less painful if you use a CSS file and include it in the html part of your page.


    Code:
    <head>
    <title>XXX</title>
    <link href="style.css" rel="stylesheet" type="text/css">
    </head>
    part of CSS file
    Code:
    body {
    	background-color: #e6e6fa;
    	background-image:url(php-med-trans1.png);
    	background-repeat:no-repeat;
    	background-attachment:fixed;
    	background-position:top right; 
    	font-family: Arial, Tahoma, Verdana;
    	font-size: 10pt;
    	color:#000000;
    	margin-top: 0px;
    }

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    <FRAMES> and <TABLES> .... tsk tsk!

    Why can't someone type an HTML script using Notepad and just open it with their browser? You can do that on any computer without the internet. You can even do javascripting. The only time you need to use the internet is if you need server-side scripting.

    Can you describe what your script is supposed to do? I'm just not getting it.

  • #9
    New Coder
    Join Date
    Mar 2011
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Look at the link below what I'm trying to do is a more simplistic version of this.
    http://sandbox.onlinephpfunctions.com/

    There would be 2 frames the one on the left is the input for code and the one on the right would be the output displaying the result of the code.

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Ohh .. I get it now! Sorry I couldn't figure that out.

    You're also testing PHP scripting, not just HTML.

    Is there a link to your own site?
    Sometimes it helps us see better what is happening.

  • #11
    New Coder
    Join Date
    Mar 2011
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    Ohh .. I get it now! Sorry I couldn't figure that out.

    You're also testing PHP scripting, not just HTML.

    Is there a link to your own site?
    Sometimes it helps us see better what is happening.
    http://www.myaxxus.net/InternetSecur...p/generate.php

  • #12
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Right off the bat ...

    Change this:
    <FORM METHOD="post" ACTION="generate.php?page=right" TARGET="output">

    To this:
    <FORM METHOD="post" ACTION="generate.php" TARGET="output">
    <input type="hidden" name="page" value="right">

    You are using POST, so the variable called 'name' also needs to be posted. That will happen with the hidden type and won't show up on your form.

    I have no idea what TARGET="output" will do ... "output" is not an attribute of TARGET
    http://www.w3schools.com/tags/att_form_target.asp


    .

  • #13
    New Coder
    Join Date
    Sep 2013
    Posts
    17
    Thanks
    0
    Thanked 2 Times in 2 Posts
    you have two ELSE statements, that might cause the error


  •  

    Tags for this Thread

    Posting Permissions

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