chs22 Posted May 20, 2003 Share Posted May 20, 2003 I have a perl script that will take information from a form I have and shoot it into an HTML file. The only trouble is I have to create an HTML file that will accept the information and display it. I guess what I really need to know is the code for HTML to display variables (i.e. $email, $name, $address1, etc.) Then I can fool around with tables, etc. Ideally, the user visits the form, fills out their information, and clicks submit and is sent to the "results" page where their information has been appended to the "dynamic" HTML page in question. I know this can be done without the use of a DB, I just need to know how to code the HTML. Thanks! Caleb Quote Link to comment Share on other sites More sharing options...
surefire Posted May 21, 2003 Share Posted May 21, 2003 I don't mean this with even the slightest bit of animosity or elitism... but it's a tall order to ask others to write code for you... people pay good money for that. But since your request is easy and you're part of the TCH family... what the heck... just don't tell my clients. page1.htm <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p> </p> <p> </p> <form name="form1" method="post" action="page2.php"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="30%">name</td> <td width="15"> </td> <td><input name="name" type="text" id="name"></td> </tr> <tr> <td height="24">email</td> <td> </td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td>favorite color</td> <td> </td> <td><input name="color" type="text" id="color"></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td colspan="3"><div align="center"> <input type="submit" name="Submit" value="Submit"> </div></td> </tr> </table> </form> <p> </p> </body> </html> page2.php<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p>Hello, <?php print("$name"); ?>....</p> <p>Thanks for stopping by and telling me that your email is <?php print("$email"); ?> and your favorite color is <?php print("$color"); ?>.</p> <p> </p> <p>Have a nice day.</p> </body> </html> There you go. I accept Visa, MC, American Express... just kidding... sort of. Now, one thing I'll point out to you is that this little script doesn't check to make sure that name is a real name, email is a real email, or that color isn't a number. But those nifty modifications require about 50-100 extra lines of code... Anyhow, ... enjoy. Quote Link to comment Share on other sites More sharing options...
TCH-JimE Posted May 21, 2003 Share Posted May 21, 2003 Ah I see, I was thinking he wanted something far more complex then that. Thats me trying to hard again! Think I need more caffiene Jim Quote Link to comment Share on other sites More sharing options...
surefire Posted May 21, 2003 Share Posted May 21, 2003 Yeah.. there's always 50 ways to skin a cat. But the request seemed to indicate a simple solution. Personally, I don't see what value this script would be (other than amusement) since the variables dissapear into cyberspace as soon as the page is refreshed or the browser closes. No other users will see this info... But hey, chs22 didn't want a database script. (obviously other ways to do it other than db) Quote Link to comment Share on other sites More sharing options...
freddy Posted May 21, 2003 Share Posted May 21, 2003 php can save user input into a file which you could then include. This way the user info is saved and readable by others without using a database... www.php.net, www.phpbuilder.com These two site's have all the info you need... Quote Link to comment Share on other sites More sharing options...
surefire Posted May 21, 2003 Share Posted May 21, 2003 Freddy's right... One last thing and then I'll shuddup. Whether you use a database or flat file, you must use preventive coding to make sure malicious users don't a- Deface your site with naughty words or redirects to their site b- Break your site and erase your database by using sql injection and other tricks. As a general rule, database is more secure option than flat file. Quote Link to comment Share on other sites More sharing options...
TCH-JimE Posted May 21, 2003 Share Posted May 21, 2003 Hi, I think I will add to jacks comment about being quiet now, but one thing, from a guru's point of view, BACKUP! Make sure you have a backup copy of your website and database(s) so just incase it goes wrong, you can backup. You will not believe how invaluable this is, until you need it, and then you will thank your stars you did! Jim Quote Link to comment Share on other sites More sharing options...
freddy Posted May 21, 2003 Share Posted May 21, 2003 Also the page2.php shown above doesn't work since it doens't put the submitted values into the variables used... You can do this by using $_POST as shown below.. You should have something like this: ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $name = $_POST['name']; $email = $_POST['email']; $color = $_POST['color']; ?> <p>Hello, <?php echo $name; ?>....</p> <p>Thanks for stopping by and telling me that your email is <?php echo $email; ?> and your favorite color is <?php echo $color; ?>.</p> <p> </p> <p>Have a nice day.</p> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.