Jump to content
Killersites Forums

Changing .html page to .php


virtual
 Share

Recommended Posts

I am in the process of changing an html site to php to use php includes. I know nothing much else about PHP, so my question is as follows:

 

Before on my contact.html page I had the following

></pre>
<form id="form1" name="form1" method="post" action="http://outdoorhdtv.com/contact_outdoor.php"></

All my php was in the contact_outdoor.php file. Now that the contact page is to become a php page I can put the code in the same file. However I have no idea where to put it or how to change the form action.

 

Can someone explain how please.

Link to comment
Share on other sites

Let me check - you are saying that the action from the contact.html file form was to contact_outdoor.php which contains all the PHP processing code.

 

Now you want to transfer all the processing code into contact.html (which is then renamed contact.php).

 

You can do that by putting the <?php...........?> code somewhere on the page and editing the action in the form to

 

which processes in the same page by running the page through the server a second time.

 

However, you have to have the codes in the right order. You may also have to edit what happens after the form has been processed, for instance a "Thank You" message or a link to a "thank You" page. Do you want the form to continue to show after it's been submitted or be deleted?

 

It's quite common to leave the PHP processing code in a separate file and leave the action as it was in the renamed contact.php file. I leave the processing code in a separate file generally for additional security and convenience.

Link to comment
Share on other sites

For future reference, here is a "Redux" form file that shows how to handle a form on a single page.

>
$page_title = 'redux';

// Check if the form has been submitted.
if (isset($_POST['submitted'])) {

// handle form script here

} // End of main isset() IF.

// Leave the PHP section and create the HTML form.
?>
Build postal code file
</pre>
<form action="" method="post">

File: 




</form>

Notice the 'hidden' submitted value that is used to determine whether to perform the php code. It ignores handling the form data and processing the php section unless the hidden value "isset", like on the initial presentation of the form.

As noted above, sometimes it is preferable to use the multiple files.

Link to comment
Share on other sites

Thanks for that Jim, but that is total "geek speak" to me, I just don't get PHP and programming. I took 3 courses and the teachers all told me my brain just doesn't work that way...:D!!! I was most miffed, as I never had trouble learning anything before.

I'll just stick with the multiple file method which I have tried and tested over time.

Link to comment
Share on other sites

Hello, I emphasize, I hate the backend form stuff, takes forever! I used multiple files, and still submited the errors/thank you responce to the same page here... http://www.visibilityinherit.com/code/jquery-ajaxsubmit.php

 

But if you just want to submit to the same page, then submiting the form back to itself (as shown above) is the far easier way to go.

Edited by Eric
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...