PDA

View Full Version : Adding a registration form to access pdf docs


Stuart H
07-16-2004, 11:04 AM
Hi guys - I need help with creating a small registration form for my site www.bii-compliance.com. The idea being that when someone wants to view a pdf document on my site they are directed to a registration form with fields - name, organisation, email, and telephone number being optional. If anyone out there has an idea how I can achieve this best please let me know as I have no idea how to write it.

Thanks all.

raf
07-16-2004, 02:56 PM
not sure about your setup.
are these pdf'sshared by multiple users, or does every user has his own pdf?

you can passwordprotect your pdf's.

If they are multiuser, then you should supply them with the password after processing their registrationform. (sending them the pwd)

i they are userspecific, then you can use the registrationform to have them entere a pwd, that you'll then use when you dynamically create the PDF's.
i've done something like that recently, dynamically creating and encoding the PDF with PHP.

Stuart H
07-16-2004, 03:48 PM
Hi Raf,
Thanks for the help.

I know how to password protect PDF documents as well as grant certain permissions such as only high res printing. This is not what I am trying to achieve.

As I said in my original post I would like to have a form that must be filled in before viewing any of my PDF docs. Example - PDF1 is clicked and then the surfer is directed to a registration form where they enter name, organisation, tel number and email - The surfer then clicks subit and I recieve the users details while he/she views the pdf document.

If this clears up my original email and you can still help I would very much like to hear from you Raf.

Thanks again.

raf
07-16-2004, 07:19 PM
well, i don't know your situation, but i think it's only possible if you dynamically create the pdf. Thenit rather easy, but i don't know if that is possible.

Another sollution would be to store the pdf's somewhere in a folfder that is not accesible from the web.
Then if the user request a pdf --> instead of links to the pdf, you put a link up to your php-page with the pdf's name or reference in the querystring. You register the pdf-reference from the querystring in a sessionvariable and show the form. After processing the form, you copy the requested pdf file from the protected directory to a directory that is accesible from the web, and you then display a link to this copied version. You can then delete the pdf's when then leave your site or run a cron to delete the pdf's after 30 minutes or so.

But just building them dynamically, after pulling the content from a db, is a lot easier and securer.

Stuart H
07-16-2004, 07:28 PM
Raf your getting far too complicated!!! All I want is a registration form on a web page that is linked straight to a pdf once the forms have been filled in!!

I know this is a simple thing to do for most of you people out there but its not if you've never done it before!!

There is not 'a situation' as you keep putting it. Its just that I dont know how to create a form!!

Cheers

Stuart H
07-16-2004, 07:31 PM
OOooh and after the details on the form are filled in they are emailed to me.

Just like my second post explaines

raf
07-16-2004, 08:44 PM
euh...
if you want this:
- user clicks link to pdf
- user gets registrationform
- user fills in form and submits it
- form is processed and if filled out correctly
- user gets pdf.

Then you'll need to do exactly like i posted. If you are not concerned that the user could request the pdf by calling it directly (typing in the adress or so), then you can skip the copying and deleting.

But you'll always need to slip in the server side scripting to pull the requested pdf from a querystring (1 line of code) and do the form processing (10 lines of code?) and mailaction (1 line of code).
including the little filecopying and deleting it later, will involve about 5 extra lines of code.
If there is only one pdf file they can request, then you can save out another line of code since you then don't need to pull the fileadress from the querystring.

so ... do you want to try this on? If not, there are plenty of free form-to-mail scripts freely available. All you then need to add is a link to the pdf-file, after the mail is sent.

Stuart H
07-19-2004, 07:00 PM
Thanks Raf.

As I dont have any experience buiding forms I can see I'll struggle here. If you look at either of my sites you will notice I dont use forms - Very un-professional!

If you know where I can get free form to mail scripts and a easy to use 'this is how to do it' then that would help alot.

Thanks mate.

raf
07-19-2004, 08:18 PM
ok. no problem. The first thing we need to know is if your host suports a server side scripting language + which. As soon as we know that we can direct you to some scripts or i'll write you one. (probably woun't take me half an hour)

Stuart H
07-19-2004, 08:29 PM
I'm not sure if it supports PHP - Just called my admin and he sais he will check tomorrow. He knows it support ASP although this doesnt help me! With you help and from another thread on this forum I used this -

http://www.thescripts.com/serversidescripting/php/tutorials/parsingformswithphpandsendinge-mail/page0.html

I made this web page - www.bii-compliance.com/consultancy.htm
The form does not work however! Not sure if its my mistake or the server.

Good fun this!!

raf
07-19-2004, 09:09 PM
well, you don't need to nae your processing page like that. noone uses .php3 anymore.

so when yo are sure your server supports PHP, then i'll write you a smaal page to proces the form, validae the emailadress, send the mail and redirect to the pdf or a page with a link to open the pdf.
then name the PHP-file however you want (for example "sentmail.php") and change this

<FORM METHOD=POST ACTION="tellus.php3">

to

<form name="contact" id="contact" action="sentmail.php" method="post">

I see your host runs IIS. You can also use ASP to proces the form and send the mail, but you need a mailcomponent in ASP. So then you'll need to talk to your admin to find out if one is installed + which.
PHP has a build in function for this, so it's done with 1 line of code.

Stuart H
07-21-2004, 02:19 PM
Hi Raf - PHP CGI is enabled.

I have used a hosted form submission thingy for now but I 'really' do not want the ads that come with it. I was hoping I could use it to gain a greater knowledge but theres nt much for me to see!

If you fancy walking me through this little problem please let me know.
Thanks for your help.

raf
07-21-2004, 05:05 PM
all you see from that script is it's output.

i've edited your page and added the php-code in that you need to build the form, process it, send the mail and then display a succesmessage with link to the pdf-file (you need to change the adress to the pdf file that you need on line 10)

the page needs to be renamed to for instance consultancy.php (like i did). I made a multiputpose page of it where only the formsection of the page changes (you'll see what i mean).

only possible problem is that you host might be running a windows server (mail function doesn't work there). You'll need to ask him if you can edit the php.ini (something like)

SMTP = smtp.server.com
sendmail_from = whatever@hostdomain.com