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 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2009
    Location
    Boston
    Posts
    25
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question add html to php statement

    Hello All,

    I'm trying to edit a script and I need to be able to add <a href="javascript: history.go(-1)">Go Back</a> underneath the errors that the following statement generates.

    PHP Code:
    if($required_fields_check)
    {

    foreach(
    $required_fields as $value){if((!isset($_REQUEST[$value]) || empty($_REQUEST[$value])) && (!isset($_FILES[$value]['name']) || empty($_FILES[$value]['name']))){$errors[] = "Please go back and complete the following $value field";}}

    }else{ 
    how would I go about adding it to this statement? echo? where do I put it?

    Thanks,

    - Anti
    Last edited by AntiHero118; 05-06-2009 at 09:08 PM. Reason: added php code tags

  • #2
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    We don't know what happens with that $errors array, so the only thing I'm pretty sure will work is putting the link right inside that array, like
    PHP Code:
    $errors []= '<a href="javascript: history.go(-1)">Go Back</a>'
    after all the other errors have been checked.

  • Users who have thanked venegal for this post:

    AntiHero118 (05-06-2009)

  • #3
    New Coder
    Join Date
    Mar 2009
    Location
    Boston
    Posts
    25
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Sorry, I realized that I could do it with an echo.

    PHP Code:
    echo "<a href=\"javascript: history.go(-1)\">Go Back</a><br /><br />"
    works like a charm.

    Thanks!

  • #4
    Regular Coder devinemke's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    443
    Thanks
    0
    Thanked 12 Times in 11 Posts
    PHP Code:
    if ($required_fields_check)
    {
        foreach (
    $required_fields as $value)
        {
            if ((!isset(
    $_REQUEST[$value]) || empty($_REQUEST[$value])) && (!isset($_FILES[$value]['name']) || empty($_FILES[$value]['name']))) {$errors[] = $value;}
        }
        
        if (isset(
    $errors)) {echo 'Please <a href="javascript: history.go(-1)">go back</a> and complete the following fields: ' implode(', '$errors);}


  • #5
    New Coder
    Join Date
    Mar 2009
    Location
    Boston
    Posts
    25
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks devinemke, I just came back to post again because the link showed up on the thanks page even with no errors. your code fixed that

    Thanks,

    - Anti

  • #6
    New Coder
    Join Date
    Mar 2009
    Location
    Boston
    Posts
    25
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by devinemke View Post
    PHP Code:
    if ($required_fields_check)
    {
        foreach (
    $required_fields as $value)
        {
            if ((!isset(
    $_REQUEST[$value]) || empty($_REQUEST[$value])) && (!isset($_FILES[$value]['name']) || empty($_FILES[$value]['name']))) {$errors[] = $value;}
        }
        
        if (isset(
    $errors)) {echo 'Please <a href="javascript: history.go(-1)">go back</a> and complete the following fields: ' implode(', '$errors);}

    this works on one server, but not another?


  •  

    Posting Permissions

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