I'm creating a simple form on my site, example. Your name: Age: Sex: Send and wanted to know if there's a way I can have the information appear in a simple box so the user can copy past the information.
Yes, after the user presses SEND I wanted the information to be displayed in a box "text box" so that he can copy pat the information.
okay, setup a form that uses POST. example: <form name="emailer" method="post" action="contact.php"> PHP: Have input fields like: <input type="text" name="sender_name" size="30" /> <input type="text" name="sender_age" size="30" /> <input type="text" name="sender_sex" size="30" /> PHP: Have a SEND button like: <input type="submit" name="email_page" value="Submit" /> PHP: Then end the form </form> PHP: On contact.php use this code: <?php if(isset($_POST['email_page'])) { $sender_name = $_POST['sender_name']; $sender_age = $_POST['sender_age']; $sender_sex = $_POST['sender_sex']; ?> <textarea rows="6" cols="32"> Your name:<?php echo $sender_name; ?> Age:<?php echo $sender_age; ?> Sex:<?php echo $sender_sex; ?> </textarea> <?php } ?> PHP:
Noddegamra thanks for your help, that's sort of what I was looking for. This is what I wan to do on my site. Users will be presented with a form. Name: Age: Birth: Sex: send information After filling the form and pressing send I want something ,like this to appear. My name is "name" and I'm "age". The name and age should be information he provided in the form. The last part of what I want to do is have it all printed so he can copy past the complete sentence.
Noddegamra gave you an answer that can be adapted to do exactly what you're asking for, just keep in mind that you should not directly redisplay user input on a page EVER. You may want to read a very simple PHP tutorial.
Thanks, I found a similar tutorial on another site and got things going. All I wanted to do is finish of by having the message displayed in a nice box for my readers to copy/past.
Yes. Always make sure you validate input and prevent browser hacking attempts. But for now, it's beyond the scope of my answer. for your desired result you need to replace the textarea bit with (for example): <textarea rows="6" cols="32"> <p>Hi, my name is <?php echo $sender_name; ?> and I am <?php echo $sender_age; ?> years old.</p> </textarea> PHP: Remember, once you have recieved the data, you can always output it as you want. There are no limitations to how you can present it (within reason). If you want to learn more about PHP, HTML, and forms I highly recommend looking at the easy-to-follow tutorials provided by http://www.tizag.com/phpT/
I did manage to get everything working fine, the only problem I'm still facing is the way in which the results are displayed after pressing the submit query button. Currently it opens an ugly white windows with the desired information, go here and fill the form to see if you want. I'm still having a few problems getting that same information to appear bellow the form in a textbox insted of opening a new window. That's the site I used to get my information, it was very helpful.
The reason I'm not opting for a ready made form is that I want to learn how to do it myself. It's something that I wanted to do by hand to see how it works.
Hi undir please take a look at my site, you'll understand better what I'm trying to do. This is all the code I currently have on my firm. The Form: <script type="text/javascript" src="prototype.js"></script> <script type="text/javascript"> function Process(form) { var myAjax = new Ajax.Updater( "container", "form.php", { method: "post", parameters: { name: form.name.value, age: form.age.value, } } ); return false; } </script> <table> <form action="code.php" method="post" onsubmit="Process(this); return false;"> <tr><td>Paypal ID:</td><td><input type="text" name="ID"></td></tr> <tr><td>Item name:</td><td><input type="text" name="Item"></td></tr> <tr><td>Item number:</td><td><input type="text" name="Number"></td></tr> <tr><td>Currency: </td><td> <select name="Currency"> <option>USD</option> <option>EUR</option> <option>CAD</option> </select></td></tr> <tr><td>Cost: </td><td><input type="text" name="Cost"></td></tr> <tr><td>Cicle:</td><td><input type="text" name="Cicle"></td></tr> <tr><td>Cicle unit: </td><td> <select name="CicleU"> <option>M</option> <option>Y</option> <option>D</option> </select></td></tr> <tr><td> <input type="submit"></td></tr> </form> </table> Code (markup): Code.php: <html> <body> https://www.paypal.com/cgi-bin/webscr?cmd=_xclick-subscriptions&business=<?php echo $_POST["ID"]; ?> %20&item_name=<?php echo $_POST["Item"]; ?> &item_number=<?php echo $_POST["Number"]; ?> &no_shipping=1&no_note=1currency_code=<?php echo $_POST["Currency"]; ?> &bn=PP%2dSubscriptionsBF&charset=UTF%2d8&a3=<?php echo $_POST["Cost"]; ?> &p3=<?php echo $_POST["Cicle"]; ?> &t3=<?php echo $_POST["CicleU"]; ?>&src=1&sra=1 </body> </html> Code (markup): This is what I want to have at the end example
This uses ajax. Do you want to do it in ajax? Ill write something for you if you want. Just give me till tomorrow. OK?
The code I have there was taken from this thread. I've been trying to follow everyone's help but it never seems to work at the end. You don't have to right the code for me but if you think that's the best option I really appreciate it. My idea was to create something really simple but I guess it turned out a little more complicated than I expected.
I think you have a little problem with your syntax, you should not be redirecting to code.php. You should include that code in form.php
Do you understand php and javascript? http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm Have a look at the code and you will see that with very little changes to that you can achieve what you want.