senca99 Posted October 27, 2009 Share Posted October 27, 2009 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 Quote Link to comment Share on other sites More sharing options...
seanlim Posted October 27, 2009 Share Posted October 27, 2009 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. Quote Link to comment Share on other sites More sharing options...
senca99 Posted October 27, 2009 Author Share Posted October 27, 2009 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 ? Quote Link to comment Share on other sites More sharing options...
haku Posted October 27, 2009 Share Posted October 27, 2009 Yes. You can put php in html, and html in php. This: <div><?php echo 'this is a div'; ?></div> will output the same thing as this: <?php echo '<div>This is a div</div>'; ?> Quote Link to comment Share on other sites More sharing options...
senca99 Posted October 27, 2009 Author Share Posted October 27, 2009 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.