Web Hosting Talk







View Full Version : Question on Forms


enrique007
10-20-2005, 05:43 AM
Hi there,

I have created a "terms and conditions" form using a script for my website. I have named this form register1.php. Once users agree to terms, the get redirected to register2.php where they need to fill out their name, details,etc.

The problem that I'm having is that if users just type mywebsitename/register2.php, they get send directly to the registration page totally bypassing the "terms and conditions" (register1.php) form and I don't want that.

What can I add or what can I do to deny people access to register2.php if they haven't agreed to register1.php?(terms and conditions) maybe add a message saying that they need to agree to register1.php befoe gainning access to register2.php?


Thanks

dollar
10-20-2005, 05:47 AM
This would probably fit better in the programming area, but in any event I would do it with a simple form.

ie.

Form on register1.php posts to register2.php with a checkbox for agreeing to the terms and conditions.

On register2.php do something like

<?php
if(!$_POST['agree'] == 'true') {
header('location:register1.php');
} else { ?>

Page stuff here

<?php } ?>

enrique007
10-20-2005, 06:09 AM
hello,

thanks for that. Not sure in what part of the page to add the code, I keep getting error messages

dollar
10-20-2005, 06:15 AM
Should be at the very top. Which error message is it throwing you? Headers already started?

SoftWareRevue
10-20-2005, 06:21 AM
Moved to 'Programming Discussion.'

enrique007
10-20-2005, 06:25 AM
Yes, you right. headers already started.

Warning: Cannot modify header information - headers already sent by (output started at c:\wamp\www\alcohol\register2.php:2) in c:\wamp\www\alcohol\register2.php on line 4


I can post the full code of the page if that will help

dollar
10-20-2005, 06:31 AM
Sure wouldn't hurt ;)

Just make sure that code is at the very top without any whitespace before it and it should work.

enrique007
10-20-2005, 07:37 AM
Hi,

I moved the code to the top of the page like you said. Not getting error messages anymore but what happens is that once someone click the 'accept box' and hit continue, the page instead of going to register2.php to continue the registration, goes back to register1.php

dollar
10-20-2005, 07:43 AM
Well you have to set the form up properly.


<form name="tosagree" method="post" action="register2.php">
<input name="agree" type="checkbox" id="agree" value="true">
<input type="submit" name="Submit" value="Submit">
</form>

enrique007
10-20-2005, 08:24 AM
I made a couple of changes to the script I already had and combine with the one you gave me, seems like is working fine. Thanks for that!

Do you know anything about billing? (like billing users for services)