|
-
Aug 31st, 2009, 11:04 PM
#1
[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.
-
Sep 1st, 2009, 01:41 AM
#2
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"?
-
Sep 1st, 2009, 02:47 AM
#3
Re: Message in PHP script is displayed in other server
 Originally Posted by dee-u
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
}
?>
 Originally Posted by kows
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
-
Sep 1st, 2009, 03:57 AM
#4
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.
-
Sep 1st, 2009, 08:51 AM
#5
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. Is the script specific to any version or something?
-
Sep 1st, 2009, 08:55 AM
#6
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?
-
Sep 1st, 2009, 09:25 AM
#7
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.
-
Sep 1st, 2009, 09:31 AM
#8
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%;" ></textarea>
</p>
<p>
<input type="submit" name="submit" value="Submit" />
</p>
</fieldset>
</form>
</div>
</div>
-
Sep 1st, 2009, 09:36 AM
#9
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
-
Sep 1st, 2009, 09:39 AM
#10
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.
-
Sep 1st, 2009, 09:52 AM
#11
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?
-
Sep 1st, 2009, 09:59 AM
#12
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
-
Sep 1st, 2009, 10:02 AM
#13
Re: Message in PHP script is displayed in other server
Pardon? You mean I should change to contact.php?
-
Sep 1st, 2009, 10:03 AM
#14
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]
-
Sep 1st, 2009, 10:07 AM
#15
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.
-
Sep 1st, 2009, 11:04 AM
#16
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
-
Sep 1st, 2009, 06:25 PM
#17
Re: Message in PHP script is displayed in other server
 Originally Posted by I_Love_My_Vans
?>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
-
Sep 1st, 2009, 06:53 PM
#18
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.
-
Sep 1st, 2009, 08:21 PM
#19
Re: [RESOLVED] Message in PHP script is displayed in other server
 Originally Posted by SambaNeko
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
-
Sep 2nd, 2009, 06:44 AM
#20
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|