html - How to delete the previous output in perl CGI script? -
my html code
<html> <head> <title>hello</title> </head> <body bgcolor = pink> <form action ="hai.pl" method=post> <label>enter name</label> <input type = "text" name ="fname"> <input type = "submit" value = "go"> </form> </body> </html>
perl script
use cgi ':standard'; $firstname = param('fname'); print "<html>"; print "<head>"; print "<title>$firstname</title>"; print "</head>"; print "<body>"; print "<h2> hai $firstname </h2>"; print "</body>"; print "</html>";
when give first input html code print many more times of output different kind of input. example first time give input mkhussain . output hai mkhussain . next time give input boxer. output hai mkhussain. how can clear error?
your code should print out error. there few things wrong perl script. first need shebang indicate interpreter running file. second need print cgi prefix (the header function below) indicate type of content page.
you should include error , warnings support perl script. easier identify problems.
look at:
#!/usr/bin/perl use strick; use warnings; use cgi ':standard'; $firstname = param('fname') || ""; print header; print "<html>"; print "<head>"; print "<title>$firstname</title>"; print "</head>"; print "<body>"; print "<h2> hai $firstname </h2>"; print "</body>"; print "</html>";
again, example posted wouldn't show errors. changes made described objective.
Comments
Post a Comment