Results 1 to 20 of 20

Thread: [RESOLVED] Message in PHP script is displayed in other server

  1. #1

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Resolved [RESOLVED] Message in PHP script is displayed in other server

    This is the code, somehow I noticed that in the other server that I have tried it the messages (Please specify email., Incorrect email format., etc...) are being displayed, why is this?
    Code:
    <?php if(isset($_GET['empty_email'])){?> 
    Please specify email.<br /> 
    <?php ;}?>
    
    <?php if(isset($_GET['invalid_email'])){?> 
    Incorrect email format.<br /> 
    <?php ;}?>  
    
    <?php if(isset($_GET['empty_captcha'])){?> 
    Please specify verification code.<br /> 
    <?php ;}?> 
    
    <?php if(isset($_GET['wrong_code'])){?> 
    Wrong verification code.<br /> 
    <?php ;}?> 
    
    <?php if(isset($_GET['success'])){?> 
    Comment successfully sent.<br /> 
    <?php ;}?>
    I'm really no PHP developer and most of the stuffs I used are from searching the web so I am not sure of the answer. Thanks for anyone who could point out what I am doing wrong.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Message in PHP script is displayed in other server

    I'm not entirely sure what you're asking.

    the code you posted doesn't really mean anything. what is the desired output? what is showing up instead? where is the rest of the script? what is this "other server"?

  3. #3
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Message in PHP script is displayed in other server

    Quote Originally Posted by dee-u View Post
    This is the code, somehow I noticed that in the other server that I have tried it the messages (Please specify email., Incorrect email format., etc...) are being displayed, why is this?
    Code:
    <?php if(isset($_GET['empty_email'])){?> 
    Please specify email.<br /> 
    <?php ;}?>
    
    <?php if(isset($_GET['invalid_email'])){?> 
    Incorrect email format.<br /> 
    <?php ;}?>  
    
    <?php if(isset($_GET['empty_captcha'])){?> 
    Please specify verification code.<br /> 
    <?php ;}?> 
    
    <?php if(isset($_GET['wrong_code'])){?> 
    Wrong verification code.<br /> 
    <?php ;}?> 
    
    <?php if(isset($_GET['success'])){?> 
    Comment successfully sent.<br /> 
    <?php ;}?>
    I'm really no PHP developer and most of the stuffs I used are from searching the web so I am not sure of the answer. Thanks for anyone who could point out what I am doing wrong.
    Write it like this:
    PHP Code:
    <?php 
    if (isset($_GET['empty_email'])) 

    //Something here

    else 

    //Something else

    ?>
    Quote Originally Posted by kows View Post
    I'm not entirely sure what you're asking.

    the code you posted doesn't really mean anything. what is the desired output? what is showing up instead? where is the rest of the script? what is this "other server"?
    I think dee-u is asking why the else part of the code is being triggered!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  4. #4

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Message in PHP script is displayed in other server

    The message "Please specify email." should only be shown when there is no email but without doing anything it does show up when I just show my contact form which is hosted on another server. I will look closely at night's suggestion when I get home.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Message in PHP script is displayed in other server

    When I tried Nightwalker83's suggestion here is what is displayed when the html is shown.
    } else { Test } ?>
    Is the script specific to any version or something?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Message in PHP script is displayed in other server

    Your condition for PHP to write out "please specify email" is if $_GET['empty_email'] is set. Check the URL you're using to access the page... does it have "empty_email" anywhere in it?

  7. #7
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: Message in PHP script is displayed in other server

    PHP Code:
    <?php

    if (isset($_GET['empty_email'])) 

        
    ?>Please specify an email<br /><?php
    }

    ?>
    Does your condition (if) statement look like this? ^^^

    Please post what you currently have, and and SambaN suggested, an example link that you are using to fire this script.


    ILMV
    Last edited by I_Love_My_Vans; Sep 1st, 2009 at 09:30 AM.

  8. #8

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Message in PHP script is displayed in other server

    This is how it is. This works on one server and not on other servers I have tested.
    Code:
    <div id="outer">
    <div id="inner2">
    
    <?php if(isset($_GET['empty_email'])){?> 
    Please specify email.<br /> 
    <?php ;}?>
    
    <?php if(isset($_GET['invalid_email'])){?> 
    Incorrect email format.<br /> 
    <?php ;}?>  
    
    <?php if(isset($_GET['empty_captcha'])){?> 
    Please specify verification code.<br /> 
    <?php ;}?> 
    
    <?php if(isset($_GET['wrong_code'])){?> 
    Wrong verification code.<br /> 
    <?php ;}?> 
    
    <?php if(isset($_GET['success'])){?> 
    Comment successfully sent.<br /> 
    <?php ;}?>
    <form action="send_contact.php" method="post" >
            <fieldset style="border: none;">
            <input type="hidden" name="submit" value="submit" />
            <p>Name:<br />
              <input type="text" maxlength="50" name="name" value="" />
            </p>
            <p>Email:<br />
              <input type="text" maxlength="50" name="email" value="" />		  
            </p>
    		<p>Type verification image:<br />
              <input name="verif_box" type="text" id="verif_box""/>
    			<img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="absbottom" />
    			<br />								
            </p>
            <p>Comments:<br />
              <textarea name="comments" rows="7" cols="7" style="width: 98&#37;;" ></textarea>
            </p>
            <p>
              <input type="submit" name="submit" value="Submit" />
            </p>
            </fieldset>
          </form>
    </div>
    </div>
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  9. #9
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: Message in PHP script is displayed in other server

    It should be cleaned up as I suggested... like this:

    PHP Code:
    <div id="outer">
    <div id="inner2">

    <?php 

    if(isset($_GET['empty_email'])) {
        
    ?>Please specify email.<br /><?php
    }
    if(isset(
    $_GET['invalid_email'])) {
        
    ?>Incorrect email format.<br /><?php
    }
    if(isset(
    $_GET['empty_captcha'])){
        
    ?>Please specify verification code.<br /><?php 

    if(isset(
    $_GET['wrong_code'])){ 
        
    ?>Wrong verification code.<br /><?php 
    }
    if(isset(
    $_GET['success'])){ 
        
    ?>Comment successfully sent.<br /><?php 
    }

    ?>
    <form action="send_contact.php" method="post" >
            <fieldset style="border: none;">
            <input type="hidden" name="submit" value="submit" />
            <p>Name:<br />
              <input type="text" maxlength="50" name="name" value="" />
            </p>
            <p>Email:<br />
              <input type="text" maxlength="50" name="email" value="" />          
            </p>
            <p>Type verification image:<br />
              <input name="verif_box" type="text" id="verif_box""/>
                <img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="absbottom" />
                <br />                                
            </p>
            <p>Comments:<br />
              <textarea name="comments" rows="7" cols="7" style="width: 98%;" ></textarea>
            </p>
            <p>
              <input type="submit" name="submit" value="Submit" />
            </p>
            </fieldset>
          </form>
    </div>
    </div>

    ILMV

  10. #10

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Message in PHP script is displayed in other server

    Okay, I cleaned it up but still it show. Have a look at this. The same script works here.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  11. #11

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Message in PHP script is displayed in other server

    As odd as it is the script for the PHP is viewable when I view the source of the first link. Is it a server setting?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  12. #12
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Message in PHP script is displayed in other server

    Why are you using a .html file extension? I wasn't even aware you could do that.

    Should be .php

  13. #13

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Message in PHP script is displayed in other server

    Pardon? You mean I should change to contact.php?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  14. #14
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Message in PHP script is displayed in other server

    well, if you tell Apache to use the PHP interpreter on HTML files, it would work. but not many people would do that! from now on, make sure your PHP scripts have the right extension! if you want, you can use mod_rewrite (in an HTACCESS file) to mimic the functionality.

    Code:
    RewriteEngine On
    RewriteRule ^contact.html$ /contact.php [NC,L]

  15. #15

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Message in PHP script is displayed in other server

    ahhh... so anything that has a PHP script in it should be saved with .php extension, I thought if the whole file is PHP only then should we save it as such. Thanks guys, changing the extension worked.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  16. #16
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: [RESOLVED] Message in PHP script is displayed in other server

    For your reference, as kows mentioned, if you want to have .html files parsed as PHP, here's what you need to add to your .htaccess file:
    Code:
    AddType application/x-httpd-php .htm .html 
    AddHandler application/x-httpd-php .html .htm .php

  17. #17
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Message in PHP script is displayed in other server

    Quote Originally Posted by I_Love_My_Vans View Post
    ?>Please specify email.<br /><?php
    What is the reason for the php tags as above? The start and end tags should be enough?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  18. #18
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: [RESOLVED] Message in PHP script is displayed in other server

    What is the reason for the php tags as above? The start and end tags should be enough?
    Because that line of code exits (with "?>"), and then re-enters (with "<?php") the PHP context to write out a line of HTML. It's the same as doing this:
    Code:
    <?php
    echo "Please specify email.<br />";
    ?>
    ...and I'd say that's the preferred method when the string is so short, but if you have a particularly large block of HTML to output in the middle of your PHP script, it's easier and cleaner to do it the aforementioned way.

  19. #19
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [RESOLVED] Message in PHP script is displayed in other server

    Quote Originally Posted by SambaNeko View Post
    Because that line of code exits (with "?>"), and then re-enters (with "<?php") the PHP context to write out a line of HTML. It's the same as doing this:
    Code:
    <?php
    echo "Please specify email.<br />";
    ?>
    ...and I'd say that's the preferred method when the string is so short, but if you have a particularly large block of HTML to output in the middle of your PHP script, it's easier and cleaner to do it the aforementioned way.
    Ah, I've just been taught to echo method as you posted! It seems tidier.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  20. #20
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: [RESOLVED] Message in PHP script is displayed in other server

    Don't let VisualAd know your echoing HTML!

    I have been beaten by said member of the forums, into not echoing out HTML. PHP is an embedded language, you don't need to echo even the little one liners because of the small amount of code needed to close and re-enter the executable PHP code.

    Not only does echoing HTML make the server work more, but because it is wraped in PHP code your text editor may not highlight it, and thus it may be more difficult to spot validation errors.


    Cheers Adam!

Posting Permissions

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



Click Here to Expand Forum to Full Width