Jump to content

using a php script in my html page,script doesn't show up


senca99

Recommended Posts

hey everyone,

 

I am having trouble with something.I wanna use a php script inside my html page but the script won't show.

I'll try to explain as good as I can.

First of all I have an index.html page.This page contains 2 div's.These 2 div's are positioned next to each other.In the left div I have 2 textfields and a submit button.I want the outcome to be visible in the right div.

So I made a script which I named script.php.

I put the following code in the right div tag: (schermrechts is the right screen :) )

 

<div class="schermrechts">

 

<? include 'script.php'; ?>

</div>

 

After doing this the php icon appears in the right div.

Because the exercise with the textfields didn't work I just put a sentence in my script.php (to just make it a bit easier without the textfields and the submit button) like this:

 

<? echo "this is a test"; ?>

 

But this doesn't appear in my right div.Is there something wrong in my HTML code or is it something in my script?I red something about $_GET and $_POST but I don't know if I need to use these (or how to use these) if I just wanna show my script in my right div without having to click on something.

 

greetz

 

Link to comment
Share on other sites

you are going about this the wrong way.

 

you cannot submit a form and show the results on the same page using pure php and html.

 

firstly, your file must be named index.php for php to parse the file (unless your server parses.html files too, which is unlikely to be the case by default)

 

secondly, to achieve the effect of submitting a form on left and displaying the results on the right, you will need some client-side scripting, probably javascript/AJAX. in this case, you will need to use the $_GET/$_POST variables. Read some tutorials online on how to go about doing that.

Link to comment
Share on other sites

I made this last week but I can't remeber how it went.I know I worked with index.php but I don't know on which part.I know I used 2 div's with in the left one textfields and a submit button.When submitting the outcome would be shown in the right div by using a php script.Probably the homepage was index.php (would be logical). But is it even possible to insert HTML in PHP for making the div tags and form ?

Link to comment
Share on other sites

jup its comming back to me piece by piece :). I used the first way ==> <div><?php echo 'this is a div'; ?></div>

 

I made another php file but this time without any html code.This was the script I used to output the textfields in the right block.But I don't remember the code.I'll figure that one out I guess :).

 

Thx for the help guys!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.