7 Replies - 762 Views - Last Post: 30 May 2010 - 08:25 AM Rate Topic: -----

#1 georgehowell  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 10
  • Joined: 23-April 10

HTML form with some PHP

Posted 30 May 2010 - 01:11 AM

hi gurus
i've got this small problem with this HTML form, that the PHP code is appearing in some of the input-fields unintentionally.
Does anyone know how to hide it?
thanx, georgehowell

Attached image(s)

  • Attached Image

Is This A Good Question/Topic? 0
  • +

Replies To: HTML form with some PHP

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5191
  • View blog
  • Posts: 26,903
  • Joined: 10-May 07

Re: HTML form with some PHP

Posted 30 May 2010 - 01:32 AM

Without posting your code... I can only guess that you didn't close the PHP brackets. Can you post your code or give us a link to view it live?
Was This Post Helpful? 0
  • +
  • -

#3 georgehowell  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 10
  • Joined: 23-April 10

Re: HTML form with some PHP

Posted 30 May 2010 - 01:46 AM

sorry
here's the code

<form action="Search.php" method="get">
<input type="text" name="search" class="phpsearch_input" size="18" autocomplete="off" value="<?php echo (isset($_REQUEST['search']))?htmlspecialchars($_REQUEST['search']):'';?>"/>
<input type="submit" name="go" value="<?php echo $this->label('Search Site');?>" class="serviceNav_button"/>
</form>

here's the link to the site as well:
http://relativity.ne...Zone/index.html

(it's a school project)

thanx
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5191
  • View blog
  • Posts: 26,903
  • Joined: 10-May 07

Re: HTML form with some PHP

Posted 30 May 2010 - 01:54 AM

There is your problem... you have php code in an html file. HTML is executed on the browser & php is executed on the server.

Does your webserver allow for PHP code?

Try renaming the file to .php
Was This Post Helpful? 0
  • +
  • -

#5 georgehowell  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 10
  • Joined: 23-April 10

Re: HTML form with some PHP

Posted 30 May 2010 - 02:04 AM

thanx for the reply no2pencil
i've had other problems with this form whilst with a .php extension, but i suppose those will have to be overcome... if a "one won't work with the other" scenario, as in the form.
your help is much appreciated
George
Was This Post Helpful? 0
  • +
  • -

#6 atik97  Icon User is offline

  • ???
  • member icon

Reputation: 144
  • View blog
  • Posts: 715
  • Joined: 16-September 08

Re: HTML form with some PHP

Posted 30 May 2010 - 02:18 AM

As mentioned by no2pencil, you need to change the file extension to .php in order to php code to be executed by server.

Also, i would like to add another issue,
<input type="submit" name="go" value="<?php echo $this->label('Search Site');?>" class="serviceNav_button"/>



Here you are using $this in non-object context, which will generate error. To set the value of submit button as "Search Site", you don't need to use PHP code, just modify it as -
<input type="submit" name="go" value="Search Site" class="serviceNav_button"/>


Was This Post Helpful? 0
  • +
  • -

#7 ShaneK  Icon User is offline

  • require_once("brain.php"); //Fatal error :/
  • member icon

Reputation: 240
  • View blog
  • Posts: 1,224
  • Joined: 10-May 09

Re: HTML form with some PHP

Posted 30 May 2010 - 08:01 AM

View Postatik97, on 30 May 2010 - 02:18 AM, said:

Here you are using $this in non-object context, which will generate error. To set the value of submit button as "Search Site", you don't need to use PHP code, just modify it as -
<input type="submit" name="go" value="Search Site" class="serviceNav_button"/>



Well, it's possible that it's in an object context, it's just not likely. You can jump out of and back into HTML in PHP, it's just not good...at all...

I actually have header and footer files that use $this->doSomething(); even though there's no apparent class, because they're included and eval'd in a class (which is based in a templateClass.php file)...just wanted to point that out to you :P

It's actually impossible to tell with what little code he posted though.

Yours,
Shane~
Was This Post Helpful? 1
  • +
  • -

#8 atik97  Icon User is offline

  • ???
  • member icon

Reputation: 144
  • View blog
  • Posts: 715
  • Joined: 16-September 08

Re: HTML form with some PHP

Posted 30 May 2010 - 08:25 AM

@ShaneK,
Thanks for pointing out that.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1