["PHP_SELF"] help!

Discussion in 'PHP' started by vivido, Jan 2, 2008.

  1. #1
    I am using the following to show up the thank you message in my contact us form.

    I need to show up a separate thankyou.html page. What should I define for that in the code?

    Thank you.

    vivido

    
    
    if(isset($_POST["commit"]))   
    
    {?>                           
    
    Thank you for contacting us. We will revert back to you soon. 
    
     <? }?>
    
    <form action="<? print $_SERVER["PHP_SELF"] ?>" method="post" enctype="multipart/form-data" name="FeedbackForm" id="two">
    
    
    PHP:

     
    vivido, Jan 2, 2008 IP
  2. goliathus

    goliathus Peon

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <?php
    if(isset($_POST["commit"]))   
    {
         include "thankyou.html";
    }
    ?>
    
    <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" enctype="multipart/form-data" name="FeedbackForm" id="two">
    
    PHP:
    just a tip: Use <?php instead of <? ... some PHP servers needs it ... And also echo is better than print :)
     
    goliathus, Jan 2, 2008 IP
  3. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    #3
    Your code won't work. Mine will though:
    <?php
    if(isset($_POST["commit"]))   
    {
         include("thankyou.html");
    }
    ?>
    
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="FeedbackForm" id="two">
    Code (markup):
     
    papa_face, Jan 2, 2008 IP
  4. goliathus

    goliathus Peon

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    WTF? include "thankyou.html"; works the as well as include("thankyou.html"); .... you should try it before you post this comment ...
     
    goliathus, Jan 2, 2008 IP
  5. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    And why is that?

    @OP:
    You should use $_SERVER['SCRIPT_NAME'] instead of $_SERVER['PHP_SELF'] because $_SERVER['PHP_SELF'] is liable to XSS.
     
    MMJ, Jan 2, 2008 IP
  6. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    #6
    Erm excuse me!
    <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" enctype="multipart/form-data" name="FeedbackForm" id="two">
    
    Code (markup):
    Which will produce an unexpected error because of your quotes. It is you that should try it before you comment!
     
    papa_face, Jan 2, 2008 IP
  7. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Ouch, this is a bit embarrassing for you.

    No comment.
     
    MMJ, Jan 3, 2008 IP
  8. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Some people should really think and then read what they type and more importantly test their own code before posting.

    tut tut tut.
     
    LittleJonSupportSite, Jan 3, 2008 IP
  9. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    #9
    lmao sorry, I have no idea why I thought it would produce an error :confused::confused::confused:
    Oh well, everyone makes mistakes lol.
     
    papa_face, Jan 3, 2008 IP
  10. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #10

    Exactly. Everyone makes them then reads the error logs and fixes them right!

    Now if there was only an error log for "life"

    Hmmmm

    Next project....
     
    LittleJonSupportSite, Jan 3, 2008 IP