Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://423438]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2018-02-21 19:12 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (287 votes). Check out past polls.