/    Sign up×
Community /Pin to ProfileBookmark

PHP scripting

im new to php so heres a basic question for you, hope it makes sense.

im designing a website with php, im wanting to have a search form on the index page, do i create the script with a separate file, say search.php and just include that in the home page, index.htm when you call the form.

or can you include the php script within the whole page?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@Stephen_PhilbinSep 13.2004 — You just write your php in with your html.
Copy linkTweet thisAlerts:
@dennicauthorSep 13.2004 — ok, so that means that anyone can view the source code for the php cant they?
Copy linkTweet thisAlerts:
@solavarSep 13.2004 — No one can view the source code of your PHP.

That's the beauty of it!

When someone requests a page that has a .php extension, the webserver reads the source code and constructs a .html file which is then sent to the browser.
Copy linkTweet thisAlerts:
@bestwebauctionsSep 13.2004 — create the script with a separate file, say search.php and [/QUOTE]

I find it easier to change things if I use the content of a page as incuded, in my html / php it's easier to change them on they fly than to build several pages.

These are all the lines I use in an "index.php" page.

[code=php]
<?
error_reporting(0);
include ('headder.php');
include ('body.php');
include ('footer.php');
?>[/code]
Copy linkTweet thisAlerts:
@HellspireSep 13.2004 — I shall point out the fairly obvious. If you wish to use your search engine with php on any file of your site, you will need to rename all their extensions with .php (if the processing of the form is done on that page itself, even then it is simpler to do it the way i will now mention) or have the form action go to an external file that will process the form, search and appropriate results and if you have an exact match option, you could direct them back to the html page in question. Note that the only way to make your site searchable is to either use the file read functions or to build a search index yourself. *scratches head*

Also if i may point out, php does not produce a .html page, I dont know who told anyone that, but what it does is parse the php information, and return the output of the file (script,html,text, and otherwise) to the browser. Categorizing it as an html processer is a severly limited assumption =p. ? ?

Good luck.
×

Success!

Help @dennic spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...