how would i go about doing this? I have several html forms that i have made php scripts to insert the data into mysql databases.
What I have gotten it to do so far, is give me a blank page with confirmation messages saying the it connected to the database and inserted the data.
What I would like for it to do, is give a brief confirmation message, and then go back to the form so that the end user can insert more data without hitting the back button and hitting the reset button on the form to clear it.
The digging that I have done, has lead me to $_SERVER['PHP_SELF'] as the form action, but where do I put the actual form handling script in the document? before the html? after? in the middle? Any help would be greatly appreciated

Recommended Answers

All 2 Replies

Do your php at the top, before the doctype and html tags. The server doesn't care where you put the php. It just reads the script top to bottom. Put all the php that you can before the html. That way all you have to do in the html body is echo or print variables.

hmm... not neccessarily.

You can also split it up in two html-pages if you want.

<?
if($set==true){
?>
<html>
... following page 1
<?
}else{
?>
<html>
... following page 1
<?

Or if you want to use the same layout:

<html>
<body>
Style, style, style
<?
if($set==true){
?>
Congratulation! You are a member!
<?}else{?>
Please insert your name.... *form*
<?}?>
</body>
</html>

keep in mind, as buddylee says, the server doesn't bother about your html. It executes the php-commands and outputs its result. HTML is then rendered by the browser.

Greetings
Simon

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.