Jump to content

[SOLVED] PHP form


mitcho

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/102450-solved-php-form/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524668
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524669
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524671
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/102450-solved-php-form/#findComment-524673
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.