Need Help With Simple PHP Output

Discussion in 'PHP' started by jpinheiro, Aug 2, 2008.

  1. #1
    ok theres 2 pages index.php and output.php

    this is Index.php
    
    <form action="output.php" method="post"> 
    Website URL: Without "http://www." <input type="text" name="url"  /><br />
    Website Title: <input type="text" name="text"  /> 
    <input type="submit" />
    </form>
    
    PHP:


    this is output.php
    
    <body>
    <br><br><br><center><?php include("menutop.php"); ?>
    <?php
    
    $url = $_POST['url'];
    $text = $_POST['text'];
    
    echo "Generated HyperLink: <a href="http://www.$url">$text</a>"
    
    ?>
    PHP:
    Why Does this not work?
     
    jpinheiro, Aug 2, 2008 IP
  2. Hallent

    Hallent Peon

    Messages:
    65
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try

    echo "Generated HyperLink: <a href=\"http://www.$url\">$text</a>";

    or
    echo 'Generated HyperLink: <a href="http://www.'.$url.'">'.$text.'</a>';
     
    Hallent, Aug 2, 2008 IP
  3. CarcaBot

    CarcaBot Active Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Try this code :
    <body>
    <br><br><br><center><?php include("menutop.php"); ?>
    <?
    if(isset($_POST['submit'])){
    $url = $_POST['url'];
    $text = $_POST['text'];
    
    echo "Generated HyperLink: <a href=\"http://www.$url\">$text</a>";
    }
    else {
    echo  '<form action="" method="post"> 
    Website URL: Without "http://www." <input type="text" name="url"  /><br />
    Website Title: <input type="text" name="text"  /> 
    <input type="submit" name="submit" />
    </form>';
    }
    ?>
    PHP:
    in this wai the problem is fix and u use only 1 page :)
     
    CarcaBot, Aug 2, 2008 IP
  4. jpinheiro

    jpinheiro Peon

    Messages:
    1,211
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    0
    #4
    thank you i solved already thank you for replys
     
    jpinheiro, Aug 2, 2008 IP
  5. lovelycesar

    lovelycesar Peon

    Messages:
    145
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    but that form will not run properly if you don't control entered variables
     
    lovelycesar, Aug 4, 2008 IP