Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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 studying the Monastery: (5)
As of 2018-06-24 20:48 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.