6 Replies - 643 Views - Last Post: 31 October 2013 - 08:46 AM

#1 MissPea  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 03-February 10

Access HTML form information and redirect

Posted 31 October 2013 - 03:33 AM

Hello everyone,

I need some help with an HTML form. How do I read information people enter into an HTML form I have on my site? Also, how do I redirect people to a thank you page once they click the "Submit" button?

Thanks!
Is This A Good Question/Topic? 0
  • +

Replies To: Access HTML form information and redirect

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: Access HTML form information and redirect

Posted 31 October 2013 - 05:19 AM

Hey.

Depends on how you want to use the data. You can either have the form submit to a server-side page - such as PHP or .NET - and process it there, or you can read it client-side with Javascript. The "typical" use-case is to send it to a server-side page where it's processed and stored.

All you have to do for that in HTML is to set the "action" attribute on the form to the path of the server-side script meant to process it. Then all the data in the form would be sent there when the form submits.

To redirect people to a thank you page, you could use server-side scripting for that. Or you could simply have the action page itself print a thank you message. The latter would make more sense in most situations.
Was This Post Helpful? 0
  • +
  • -

#3 MissPea  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 03-February 10

Re: Access HTML form information and redirect

Posted 31 October 2013 - 07:50 AM

Thanks so much for replying. I just need to be able to read the data submitted in the form. Could you please explain in a little more detail how I set up a server-side page for the data to be sent to, what markup I need to include in my form in order to send it to the server side page, and how to access the server side page in order to read the data?

As for the redirect, is it possible to use an action for two different things? I mean, if I use it to send the form data to a server side page, can I still use the action to print a thank you message? If so, how do I do this?
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: Access HTML form information and redirect

Posted 31 October 2013 - 08:22 AM

The first thing you need to do is pick a server-side language, and then learn how to use it. What you are proposing involves the use of a language like PHP or ASP.NET, as well as a database system. MySQL and MSSQL would be the preferred databases for those two languages, respectively. - You need to know how to accept, store and then finally read the data in your chosen language, using your chosen database system. This is far more complicated than just adding some HTML markup; it's actual programming.

Quote

... what markup I need to include in my form in order to send it to the server side page ...

You only need to add/change the "action" attribute, to point it to the server-side page. No other changes have to be made. (Unless you're using Javascript to mess with the submission event, of course.)

Quote

As for the redirect, is it possible to use an action for two different things?

No. The action does one thing: it redirects the browser to the specified location, sending the data along. After that it's done; the browser has gone to another page and the action is no longer relevant. If you want to redirect after that, it has to happen in the page the action redirected to.

You can avoid this by using Javascript and AJAX, but that is a totally different scenario. I wouldn't suggest that before getting used to the "old fashioned" way of submitting forms. It's a sort of core concept that needs to be understood first.
Was This Post Helpful? 0
  • +
  • -

#5 MissPea  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 03-February 10

Re: Access HTML form information and redirect

Posted 31 October 2013 - 08:28 AM

Wow, this is a lot more complicated than I thought. But surely there's an easier way to do this. I mean, almost every website has a form of some kind, so how do site administrators/maintainers access information submitted in, say, a contact form?
Was This Post Helpful? 0
  • +
  • -

#6 MissPea  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 03-February 10

Re: Access HTML form information and redirect

Posted 31 October 2013 - 08:35 AM

What if I just use a mailto: action instead? But if I use the action attribute for mailto:, then how do I display a thank you message, or send the user to a thank you page?

Grrrr, this is really giving me a headache!
Was This Post Helpful? 0
  • +
  • -

#7 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: Access HTML form information and redirect

Posted 31 October 2013 - 08:46 AM

Quote

But surely there's an easier way to do this. I mean, almost every website has a form of some kind...

Almost every website is backed by a server-side language these days. Very few serious sites exist anymore that are purely client-side. It's tends to be far less effort for administrators to put up a cookie-cutter WordPress site (which is PHP based) and using it's admin controls to update the content, than to put up a static HTML site and update the contents manually through something like FTP or SSH.

Keep in mind, as well, that this kind of form processing is not complicated for anybody familiar with these technologies. It's a trivial task for even an amateur PHP/.NET developer. - And this is expected of "Web Developers" these days. Client-side knowledge alone is not enough to build websites for the modern web.

Quote

What if I just use a mailto: action instead?

That's an option, but like I say, the action only does one thing, and that would be the only thing it would do. Unless you use Javascript. - Do you know how to use Javascript? Can you create functions and attach them to events? If you do, then you could open a mailto protocol in a new window and then redirect the current window.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1