Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-17-2009, 10:02 AM PHP Question
Novice Talker

Posts: 5
Trades: 0
Join Date: Sep 2009
Posts: 1

Question
Hi, Everyone.
I have a website and i have a TOS page on it. I was wondering how to make the tos page load and once you click I Agree, the actual page comes up. For example here is a site that has that: ghbsys.net

As you see once you enter their site, there Terms of Service page comes up and once you click I agree there main page comes up. Please let me know how to do this. Thanks

Last edited by chrishirst; 09-17-2009 at 10:05 AM..
Razor1337 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-17-2009, 10:08 AM Re: PHP Question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
check for a cookie on page access, if not there or false then show the ToS then set/create a cookie when the page is submitted.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-17-2009, 10:10 AM Re: PHP Question
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
A couple things that are useful to know about: PHP and Forms, PHP Sessions
The basic idea is to post the "terms" page to the main page, but only show it if the checkbox has been filled in, otherwise show an error message. Then, store the result in a session variable (or a cookie), and redirect the terms page if it is determined that it has already been filled out once.
__________________
Join me on
Please login or register to view this content. Registration is FREE

Last edited by wayfarer07; 09-17-2009 at 10:12 AM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 09-17-2009, 10:17 AM Re: PHP Question
Novice Talker

Posts: 5
Trades: 0
I just started php a few days ago but ill give it a shot.

so wait lets just say this is my tos page:



PHP Code:
<html>
<
body>

<
h1>My Tos Page</h>

etc...
<
form name="form1" method="post">
  <
input type="hidden" name="welcome">
  <
input type="checkbox" name="acceptTOS" value="accept"I Accept the Terms of Service!<br>
  
Click here to <input type="submit" name="Enter" disabled>
</
form>

</
body>
</
html
What exactly would i have to do? Cause im confused sorry.

Thanks for the help and quick replies

Last edited by Razor1337; 09-17-2009 at 10:19 AM..
Razor1337 is offline
Reply With Quote
View Public Profile
 
Old 09-17-2009, 10:39 AM Re: PHP Question
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
To start your form will need an ACTION attribute. action="name-of-page.php". This will cause the form to target the page in question.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 09-17-2009, 10:44 AM Re: PHP Question
Novice Talker

Posts: 5
Trades: 0
ok so if i do this in my form:

PHP Code:
<form name="form1" action="tos.php" method="post">
<
input type="checkbox" name="acceptTOS" value="accept" />  I Accept the Terms of Service!<br>
<
input type="submit" value="Submit" /> 
What would go in tos.php besides <?php $_POST["acceptTOS"]; ?>

and if i start a session how would i really do it. Cause I want it so after i click accept the main page comes just like on that website.

Last edited by Razor1337; 09-17-2009 at 10:57 AM..
Razor1337 is offline
Reply With Quote
View Public Profile
 
Old 09-17-2009, 02:02 PM Re: PHP Question
bmcoll3278's Avatar
Super Talker

Posts: 118
Name: Brian Collins
Trades: 0
here is a small piece of code to do what you ask. it may get you started.
Code:
<?php

$file= $_POST['yes'];

if ($file=="yes"){


    echo "<br>your main page content goes here";
}
else

{

echo"Please accept our terms of service";
echo"<br>TOS GOES Here";
echo"<table><tr>
<td><Form action =\"index.php\"method=\"post\">
YES<input type=\"checkbox\"name=\"yes\"value=\"yes\">
<input type=\"submit\"value=\"ENTER\"></form>
</td></tr>
</table>";
}
?>
I know some one here can clean this up and make it better.
__________________
I hope to build a site with something for every one

Please login or register to view this content. Registration is FREE

Last edited by bmcoll3278; 09-17-2009 at 02:05 PM..
bmcoll3278 is offline
Reply With Quote
View Public Profile Visit bmcoll3278's homepage!
 
Old 09-17-2009, 05:34 PM Re: PHP Question
Novice Talker

Posts: 5
Trades: 0
Quote:
Originally Posted by bmcoll3278 View Post
here is a small piece of code to do what you ask. it may get you started.
Code:
<?php

$file= $_POST['yes'];

if ($file=="yes"){


    echo "<br>your main page content goes here";
}
else

{

echo"Please accept our terms of service";
echo"<br>TOS GOES Here";
echo"<table><tr>
<td><Form action =\"index.php\"method=\"post\">
YES<input type=\"checkbox\"name=\"yes\"value=\"yes\">
<input type=\"submit\"value=\"ENTER\"></form>
</td></tr>
</table>";
}
?>
I know some one here can clean this up and make it better.
Thanks a Bunch Helped me out a lot, but is there a way to set a cookie liek TOS_ACCEPT and if that cookies set your main page content comes up only?
Razor1337 is offline
Reply With Quote
View Public Profile
 
Old 09-18-2009, 11:54 AM Questions (cookies)
Novice Talker

Posts: 5
Trades: 0
Hi, I have a question for all of you that are good in php.

Well heres the deal..... I have a index.php page it contains something like this:


PHP Code:
                            <?php 

$accepted 
'yes'
setcookie("TOS"$acceptedtime()+3600);   
$file$accepted
$date_of_expiry time() + 6000 
if (
$file=="yes"){ 


    echo 
"My Main Page Content"

else 



echo
"Please accept our terms of service"
echo
"My ToS"
echo

<Form action =\"index.php\"method=\"post\"> 
I Agree To The Terms!<input type=\"checkbox\"name=\"yes\"value=\"yes\"> 
<input type=\"submit\"value=\"Submit\"> </form> 
"



?>
After a little thinking and help from people i got the cookie to set after the submit button is clicked.
And I ended up with this:
PHP Code:
<?php 
if(isset($_POST['submit'])) 

$accepted 'yes'
setcookie("TOS"$acceptedtime()+3600);   
$file$accepted
$date_of_expiry time() + 6000 
if (
$file=="yes"){ 


    echo 
"My Main Page Content"


else 



echo
"Please accept our terms of service"
echo
"My ToS"
echo

<Form action =\"index.php\"method=\"post\"> 
I Agree To The Terms!<input type=\"checkbox\"name=\"yes\"value=\"yes\"> 
<input type=\"submit\"value=\"Submit\" name=\"submit\"> </form> 
"



?>


Now the problem is the When ever you reload the page, the tos part comes up. How do I make it so after the cookie is set only the main page content shows?

Last edited by Razor1337; 09-18-2009 at 11:56 AM..
Razor1337 is offline
Reply With Quote
View Public Profile
 
Old 09-18-2009, 12:05 PM Re: PHP Question
Super Talker

Posts: 116
Name: Paul
Location: South Africa
Trades: 0
The way I see it there are a couple of ways you can go about doing this, it just depends on what your requirements are, I will list some various ways, from easiest to the more difficult.

Easiest
Have you tos page as the first page when entering your site, ie: http://www.example.com/index.php will have the contents of your tos and 2 buttons one to accept and one to decline, if the user reads the agreement and hits the decline button, then you could just make that button redirect them to a page of your site that says, "You have to agree to TOS; to connect to me." lol please do not really say that, anyway you get the idea, so that could be on a page like http://www.example.com/decline.php, and you could include a hyperlink to take them back to the home page so they can accept if they like. If the client clicks on accept then you could just redirect them to the home page of your site, ie: http://www.example.com/home.php
This way only uses hyperlinks and no forms, it is super easy to implement but has some good points and bad, the good point is that it is easy to do, and the client will not have their computer jumping up and down about someone trying to send them a cookie, or their spyware application, the bad side is that every time the user goes back to your site they will have to accept the tos again. Using this same model of implementation you could also make your error and your main site on the same page, ie: join your decline.php and home.php in the same file with an if statement.
Alternatively you could stick with more difficult cookie or session variables, it is up to you, let me know what you choose, and I will try and help where possible.
__________________
This was my latest holiday in
Please login or register to view this content. Registration is FREE
South Africa.
This was my favorite adventure holiday in
Please login or register to view this content. Registration is FREE
scorpioserve is offline
Reply With Quote
View Public Profile
 
Old 09-18-2009, 06:20 PM Re: PHP Question
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I'll give you some help with pseudo code. You just make php out of it, and if you dont know how to do a specific task, use Google. If you dont know how to set and read a cookie, search Google for "php cookies tutorial".

First, the page with your terms. Name it index.php (your normal index.php will be index2.php).
PHP Code:
<?php

read cookie

if (user has already accepted terms) {
   
redirect to index2.php
   
and terminate script
}

if (
form has been sent) {
   if (
user accepted terms) {
      
set cookie
      redirect to index2
.php
      
and terminate script
   
} else {
      
show error messagetell user she must accept to see page
   
}
}

Show the terms and a form where user can agree and submit

?>
This should help you out a bit, and work pretty good. However, of course you can still just enter index2.php in your browser to get to the page without seing the terms (evan though it's unlikely). If you want to make sure they have accepted the terms, add this to all your other pages, in the top.

PHP Code:
<?php

read cookie

if (user havn't accepted terms) {
   redirect to index.php
   and terminate script
}

?>
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 09-18-2009, 07:04 PM Re: Questions (cookies)
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Aha, you made a new thread...
Read my post in your old thread and work your way from there.

And just for the record, you could have kept writing in the old thread instead of making a new with the same subject/problem.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 09-18-2009, 07:43 PM Re: PHP Question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
threads merged
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to PHP Question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.54499 seconds with 12 queries