mitcho Posted April 23, 2008 Share Posted April 23, 2008 Hi all. I've got a question about a PHP form i am building. I have contact forms before but nothing like this. I have a form with 3 text fields: name, email, phone. And 1 text box: poem. Basically people type in the details and type a poem into the text box. There would be two buttons at the bottom of the form: Submit & Preview Print. I am ok with sending the email but the preview print is what i am having trouble with. I have a HTML template that i want to populate with the text entered into the poem text box so that people can print their poem as well. Any help would be much appreciated guys. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/102450-solved-php-form/ Share on other sites More sharing options...
mitcho Posted April 23, 2008 Author Share Posted April 23, 2008 this topic should have been called "PHP form with preview" - if a moderator could change this would be much appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524656 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 Woops, I accidentally skipped over this topic. You might need to use some Javascript to change a hidden input's name dynamically based on the button clicked, which would then get passed to the PHP page, which would perform the appropriate action. Quote Link to comment https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524657 Share on other sites More sharing options...
mitcho Posted April 23, 2008 Author Share Posted April 23, 2008 Ok - hidden inputs? - my n00b alarm is ringing! Quote Link to comment https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524665 Share on other sites More sharing options...
Fadion Posted April 23, 2008 Share Posted April 23, 2008 Woops, I accidentally skipped over this topic. You might need to use some Javascript to change a hidden input's name dynamically based on the button clicked, which would then get passed to the PHP page, which would perform the appropriate action. Actually i'd be very curious to see some real code on this. Ive wanted to do smth like this some time ago and failed on every attempt, adding that my javascript capabilities are pretty scarse. Quote Link to comment https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524668 Share on other sites More sharing options...
iarp Posted April 23, 2008 Share Posted April 23, 2008 What about having javascript pop open a window that called upon a $_SESSION['poem_submitted'] and displayed the results on another page thats opened by the pop-up like print.php As long as you commit their poem's info to the session or if it's going to be saved in a database just call upon the database or session in the pop-up window. Quote Link to comment https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524669 Share on other sites More sharing options...
Fadion Posted April 23, 2008 Share Posted April 23, 2008 The session cant be set without the form posting, and if the page is refreshed, whats the point of the preview button? U can set the form action to a different page, but u would need preview.php and process.php which cant be made with the same form :S EDIT: Ive made a previous topic quite a lot a go on about the same problem. I got many questions which were basically not-well-thinked ones and didnt answer my question, so id suggest to think it well before posting and to give real code. Quote Link to comment https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524671 Share on other sites More sharing options...
iarp Posted April 23, 2008 Share Posted April 23, 2008 I thought the OP wanted to Submit & Preview Print which would imply submitting it and the end-user printing out their own copy. Unless the OP has specified that they want to be able to edit it before the final submission, then it should work. Just use mail() before calling the pop-up that way the e-mail is sent and the pop-up happens. Again commit the submitted poem to a variable accessible server wide or in a database and it should work fine. EDIT: Dammit.... it's 12:30 in the morning and i'm not going to be able to sleep.... i'ma try to make this work now. Quote Link to comment https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524673 Share on other sites More sharing options...
Fadion Posted April 23, 2008 Share Posted April 23, 2008 FROM THE OP: There would be two buttons at the bottom of the form: Submit & Preview Print Quote Link to comment https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524674 Share on other sites More sharing options...
mitcho Posted May 4, 2008 Author Share Posted May 4, 2008 Hey guys, sorry for the late response. Thanks for all your help on this one - problem solved! Quote Link to comment https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-532725 Share on other sites More sharing options...
Fadion Posted May 4, 2008 Share Posted May 4, 2008 How u solved it? Id be interested in this. Quote Link to comment https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-533079 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.