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 9 of 9
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    86
    Thanks
    8
    Thanked 0 Times in 0 Posts

    How do you echo a html hyperlink?

    Can anyone show me how to echo a html hyperlink?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    PHP Code:
    echo '<a href="http://google.com">Google</a>'
    or
    PHP Code:
    echo "<a href=\"http://google.com\">Google</a>"
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    86
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Thanks for these abduraooft, can you tell me a way to implement either of these methods into the below code. I would like the link after the last </h6> tag if possible :

    Code:
    echo "<h6>Use Back - Enter valid e-mail</h6><br />\n";
    $badinput = "<h6>Your enquiry was not submitted.</h6><br />\n";
    echo $badinput;
    die ("<h6>Please click the back button and then complete all fields marked with an *.<br /><br />Thank you.</h6> ");
    }

  • #4
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    PHP Code:
    echo "<h6>Use Back - Enter valid e-mail</h6><br />\n";
    $badinput "<h6>Your enquiry was not submitted.</h6><br />\n";
    $badinput .= '<a href="#" onClick="history.go(-1)">Back</a>';  
    echo 
    $badinput;
    die (
    "<h6>Please click the back button and then complete all fields marked with an *.<br /><br />Thank you.</h6> ");

    That will add the hyperlink back after Your enquiry was not submitted.

    You can change the href or leave it (both will work fine)

  • #5
    New Coder
    Join Date
    Oct 2007
    Posts
    86
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Thanks for your reply sea but this does not seem to work? Do you have any other ideas?

  • #6
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    There is an extra bracket, remove it and you are fine.
    PHP Code:
    echo "<h6>Use Back - Enter valid e-mail</h6><br />\n";
    $badinput "<h6>Your enquiry was not submitted.</h6><br />\n";
    $badinput .= '<a href="#" onClick="history.go(-1)">Back</a>';  
    echo 
    $badinput;
    die (
    "<h6>Please click the back button and then complete all fields marked with an *.<br /><br />Thank you.</h6> ");
    }  
    //remove this extra bracket 

  • #7
    New Coder
    Join Date
    Oct 2007
    Posts
    86
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Hi kokjj87, I need that bracket, please see full code below:
    Code:
    <?php
    
    $ip = $_POST['ip'];
    $httpref = $_POST['httpref'];
    $httpagent = $_POST['httpagent'];
    $visitor = $_POST['visitor'];
    $visitormail = $_POST['visitormail'];
    $visitorcompany = $_POST['visitorcompany'];
    $visitornumber = $_POST['visitornumber'];
    $visitoradd1 = $_POST['visitoradd1'];
    $visitoradd2 = $_POST['visitoradd2'];
    $visitoradd3 = $_POST['visitoradd3'];
    $visitorpostcode = $_POST['visitorpostcode'];
    $notes = $_POST['notes'];
    $attn = $_POST['product'];
    
    
    if (eregi('http:', $notes)) {
    die ("<h6>This form does not allow submissions of hyperlinks or code so please go back and remove such text.</h6> ");
    }
    if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
    {
    echo "<h6>Use Back - Enter valid e-mail</h6><br />\n";
    $badinput = "<h6>Your enquiry was not submitted.</h6><br />\n";
    echo $badinput;
    die ("<h6>Please click the back button and then complete all fields marked with an *.<br /><br />Thank you.</h6> ");
    }
    
    if(empty($visitor) || empty($visitormail) || empty($notes ) || empty($product )) {
    echo "<h6>Your enquiry was not submitted.</h6><br />\n";
    die ("<h6>Please click the back button and then complete all fields marked with an *.<br /><br />Thank you.</h6>");
    }
    
    $todayis = date("l, F j, Y, g:i a") ;
    
    $product = $product ;
    $subject = $product;
    
    $notes = stripcslashes($notes);
    
    $message = " $todayis [EST] \n
    Product required: $product \n
    Quote details: $notes \n
    From: $visitor ($visitormail)\n
    Company name: $visitorcompany \n
    Phone number: $visitornumber \n
    Address line 1: $visitoradd1 \n
    Address line 2: $visitoradd2 \n
    Address line 3: $visitoradd3 \n
    Postcode: $visitorpostcode \n
    Additional Info : IP = $ip \n
    Browser Info: $httpagent \n
    Referral : $httpref \n
    ";
    
    $from = "From: $visitormail\r\n";
    
    
    mail("emailaddressgoeshere", $subject, $message, $from);
    
    ?>

  • #8
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    An example of how to print the hyperlink..
    Note that you can use '\' to escape the quote

    PHP Code:
    echo "<h6>Please click the <a href=\"#\" onClick=\"history.go(-1)\">back</a> button and then complete all fields marked with an *.<br /><br />Thank you.</h6> "
    Full code
    PHP Code:
    <?php

    $ip 
    $_POST['ip'];
    $httpref $_POST['httpref'];
    $httpagent $_POST['httpagent'];
    $visitor $_POST['visitor'];
    $visitormail $_POST['visitormail'];
    $visitorcompany $_POST['visitorcompany'];
    $visitornumber $_POST['visitornumber'];
    $visitoradd1 $_POST['visitoradd1'];
    $visitoradd2 $_POST['visitoradd2'];
    $visitoradd3 $_POST['visitoradd3'];
    $visitorpostcode $_POST['visitorpostcode'];
    $notes $_POST['notes'];
    $attn $_POST['product'];


    if (
    eregi('http:'$notes)) {
    die (
    "<h6>This form does not allow submissions of hyperlinks or code so please go <a href=\"#\" onClick=\"history.go(-1)\">back<a/> and remove such text.</h6> ");
    }
    if(!
    $visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
    {
    echo 
    "<h6>Use Back - Enter valid e-mail</h6><br />\n";
    echo 
    "<h6>Your enquiry was not submitted.</h6><br />\n";

    die (
    "<h6>Please click the <a href=\"#\" onClick=\"history.go(-1)\">back</a> button and then complete all fields marked with an *.<br /><br />Thank you.</h6> ");
    }

    if(empty(
    $visitor) || empty($visitormail) || empty($notes ) || empty($product )) {
    echo 
    "<h6>Your enquiry was not submitted.</h6><br />\n";
    die (
    "<h6>Please click the <a href=\"#\" onClick=\"history.go(-1)\">back<a/> button and then complete all fields marked with an *.<br /><br />Thank you.</h6>");
    }

    $todayis date("l, F j, Y, g:i a") ;

    $product $product ;
    $subject $product;

    $notes stripcslashes($notes);

    $message " $todayis [EST] \n
    Product required: $product \n
    Quote details: $notes \n
    From: $visitor ($visitormail)\n
    Company name: $visitorcompany \n
    Phone number: $visitornumber \n
    Address line 1: $visitoradd1 \n
    Address line 2: $visitoradd2 \n
    Address line 3: $visitoradd3 \n
    Postcode: $visitorpostcode \n
    Additional Info : IP = $ip \n
    Browser Info: $httpagent \n
    Referral : $httpref \n
    "
    ;

    $from "From: $visitormail\r\n";


    mail("emailaddressgoeshere"$subject$message$from);

    ?>

  • Users who have thanked kokjj87 for this post:

    xdous (03-05-2009)

  • #9
    New Coder
    Join Date
    Oct 2007
    Posts
    86
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Thanks very much kokjj87 this has worked


  •  

    Posting Permissions

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