Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: HTML Form Submission & Save to MySQL

by Miguel (Friar)
on Jan 19, 2005 at 17:05 UTC ( #423438=note: print w/ replies, xml ) Need Help??

in reply to HTML Form Submission & Save to MySQL

For short:

#!/usr/bin/perl -w use strict; use CGI; my $q = new CGI; print $q->header, $q->start_html; if ( $q->param("name") ) { # Validate data and insert it into DB Answer(); } else { Form(); } print $q->end_html; sub Form { print $q->start_form, "Your name: ", $q->textfield("name"), " ", $q->submit, $q->end_form; } sub Answer { print "Your name is ", $q->strong($q->param("name")) }

This way you validate data AFTER printing out the document header. If you want to validate data BEFORE you need to change the way you call those functions. You cannot print anything to the browser before printing the document header.

UPDATE: OOPSSS! I misunderstood your question! I'm sorry. I thought you were passing the form via CGI. But that's not the case.

If you're using somthing like: file.HTML(form)->file.cgi(save data, send a cookie)->file.HTML(answer with data) you might need javascript to read the cookie in the 3rd step.

Comment on Re: HTML Form Submission & Save to MySQL
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://423438]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2015-07-07 20:04 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (93 votes), past polls