Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Banned
    Join Date
    Oct 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is it Session redirect or htaccess?

    I am sorry as I am a newbie.

    I would like to have people who visit my site be forced to view the index first.
    Such as, I have a view_video.php on my site and if they try to access this directly via favorites or a link they would be redirected directed to the index.php page and only be able to access pages on my site including the view_video.php page from the index page.

    Reason being I have terms and conditions that must be agreed to before entering my site and if a link outside of my site is clicked it will send a user directly to the page without having to agree. I didn't want this to be a login type session but everyone has to agree before viewing all pages on my site.

    I have searched high and low for this information and cannot seem to get it.
    Javacript? Sessions? htaccess? Cookies? I am all over the place in my brain with this right now. If anyone can provide me with the simple answer and solution to what I seek, I will be in your debt forever.

    Thank you in advance

  • #2
    Banned
    Join Date
    Oct 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is the code from a page I would like to be redirected to the index before this page can be viewed. What would I change to do this for this page.

    PHP Code:
    session_start();

    include(
    "include/config.php");

    include(
    "include/function.php");

    if (
    $config['approve'] == 1) {$active "and active = '1'";}

    if (
    $_SESSION['lang'] == ""){
      include(
    "language/en.php");
    } else {
      include(
    "language/".$_SESSION['lang'].".php");


  • #3
    Banned
    Join Date
    Oct 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I changed in view_video.php from

    PHP Code:
    session_start(); 

    include(
    "include/config.php"); 

    include(
    "include/function.php"); 

    if (
    $config['approve'] == 1) {$active "and active = '1'";} 

    if (
    $_SESSION['lang'] == ""){ 
      include(
    "language/en.php"); 
    } else { 
      include(
    "language/".$_SESSION['lang'].".php"); 

    to this

    Code:
    session_start(); 
    $_SESSION['test']='going to redirect'; 
    header('Location: index.php'); 
    die();  
    
    include("include/config.php");
    
    include("include/function.php");
    
    if ($config['approve'] == 1) {$active = "and active = '1'";}
    
    if ($_SESSION['lang'] == ""){
      include("language/en.php");
    } else {
      include("language/".$_SESSION['lang'].".php");
    }

    But now when I try to continue from the index page to the view_video.php it just keeps looping back to the index page. Someone please help me, I'm begging.

  • #4
    Banned
    Join Date
    Oct 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Someone, anyone? Please

  • #5
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Quote Originally Posted by dominickm View Post
    But now when I try to continue from the index page to the view_video.php it just keeps looping back to the index page. Someone please help me, I'm begging.
    Well,
    Code:
    session_start(); 
    $_SESSION['test']='going to redirect'; 
    header('Location: index.php'); 
    die();
    this code is why it keeps redirecting to the index page - header("location: index.php"); is telling it to do so before it executes any of the other code on the page.

    You'll need to check if a session exists, and only redirect if it does not.

  • #6
    Banned
    Join Date
    Oct 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am sorry to be so clueless about this but how do I check if a session exist before and after the index is viewed.

  • #7
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    PHP Code:
    if ($_SESSION['logged_in'] != 'true'){
    // if session variable logged_in not set to true then redirect.
    header("Location: /login.php");
    }else{
    //logged in


  • #8
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    PHP Code:
    if(!(empty($_SESSION['lang']))) {
      
    // Do Include Lang
    } else {
      
    // Do include default Lang


  • #9
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Quote Originally Posted by Element View Post
    PHP Code:
    if(!(empty($_SESSION['lang']))) {
      
    // Do Include Lang
    } else {
      
    // Do include default Lang

    wrong!
    PHP Code:
    if (!empty($_SESSION['lang'])){
    //do include
    }else{
    //dont


  • #10
    Banned
    Join Date
    Oct 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    _SESSION['lang' is calling for language selection.

    The code you provided still loops me. I go to my index and click agree and then it loops me back to the index when it tries to access the file with the code you provided.

  • #11
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    post the code for both your index page and the video page.

  • #12
    Banned
    Join Date
    Oct 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I post the code in both the video and index pages and now the index just keeps reloading over and over again.

  • #13
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    I meant post it here, so we can see what's going on.

  • #14
    Banned
    Join Date
    Oct 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is the index page I want them to agree to first.

    PHP Code:
    </head>



    <
    body link="#0000FF" vlink="#0000FF" alink="#0000FF">
    <
    div align="left">
      <
    p></font></p>
      </
    div>
    <
    div align="center">
      <
    table width="768" border="0">
        <
    tr>
          <
    td><div align="left"><span class="style7"><a href="$url/"><img src="$url/tosagreed/images/logofront.jpg"   alt="" class="moduleEntrylogo" /></a></span></div></td>
        </
    tr>
      </
    table>
      <
    table width="768" border="1"  cellpadding='10' cellspacing='0'>
          <
    tr>
            <
    td><center class="style7">
              
              <
    class="style7"><font class="option" color="#000000"><b>Welcome to </b></font><font class="option"><b><span class="style3"></span></b></font><font class="option" color="#000000"><b></b></font><font class="option" color="#000000"><b></b></font>            </p>
            </
    center>
              <
    p align="left"> <font class="smallblack">Submit and upload your adult amateur videos hereFunnyobnoxiousjaw-dropping videos of an adult nature are also welcome as well as hardcore amateur pornMovies can be uploaded and viewed for freeMost videos contain graphic sex scenes and you must agree to the terms of service before you continue! Have funbe adventurousdip into your wild side and upload your personal videos now!</font></p>
              <
    p align="center"><font class="content"> <strong><span class="style2">All participants must be at least 21 years of age.</span></strong></font></p>
              <
    center>
                <
    h2><strong>WARNING ADULT CONTENT</strong> </h2>
              </
    center>
              </
    p>          <div align="left"><span class="smallblack">If you are under 21 years of age, or if it is illegal to view adult content  in your countryplease do not continue. We cannot be held accountable  for your actionsWe are not acting in any way to manipulate you into entering this site. If you proceed to $url this means that you understand and accept responsibility for clicking further and agree to the Terms of Service hereinYou also agree by continuing to release the creators of this web site and our service provider from any and all liabilityTo continue click on the link below to verify that you are at least 21 years of age and consent to viewing adult materialOtherwise click on the &quot;do not agree&quotlink.</span><br/>
              </
    div>
              <
    FORM NAME="Terms & Conditions" action="$url/tosagreed/tostest.php" onsubmit="return checkAgeCheckBox(this)">
      <
    table border="0" cellspacing="2" cellpadding="2" align="center">
      <
    tr>
                    <
    td colspan="3" height="1"><div align="right" class="smallblack">
                      <
    div align="center">Please confirm your date of birth below.</div>
                    </
    div></td>
                  <
    tr>
                    <
    td width="85" bgcolor="#eeeeee"><font face="Arial">
                      <
    select name="cmbmonth" size="1" id="cmbmonth">
                        <
    option value="0">Month</option>
                        <
    option value="1">January</option>
                        <
    option value="2">February</option>
                        <
    option value="3">March</option>
                        <
    option value="4">April</option>
                        <
    option value="5">May</option>
                        <
    option value="6">June</option>
                        <
    option value="7">July</option>
                        <
    option value="8">August</option>
                        <
    option value="9">September</option>
                        <
    option value="10">October</option>
                        <
    option value="11">November</option>
                        <
    option value="12">December</option>
                      </
    select>
                    </
    font> </td>
                    <
    td width="43" bgcolor="#eeeeee"><select name="cmbday" id="cmbday">
                        <
    option value="0">Day</option>
                        <
    option value="1">1</option>
                        <
    option value="2">2</option>
                        <
    option value="3">3</option>
                        <
    option value="4">4</option>
                        <
    option value="5">5</option>
                        <
    option value="6">6</option>
                        <
    option value="7">7</option>
                        <
    option value="8">8</option>
                        <
    option value="9">9</option>
                        <
    option value="10">10</option>
                        <
    option value="11">11</option>
                        <
    option value="12">12</option>
                        <
    option value="13">13</option>
                        <
    option value="14">14</option>
                        <
    option value="15">15</option>
                        <
    option value="16">16</option>
                        <
    option value="17">17</option>
                        <
    option value="18">18</option>
                        <
    option value="19">19</option>
                        <
    option value="20">20</option>
                        <
    option value="21">21</option>
                        <
    option value="22">22</option>
                        <
    option value="23">23</option>
                        <
    option value="24">24</option>
                        <
    option value="25">25</option>
                        <
    option value="26">26</option>
                        <
    option value="27">27</option>
                        <
    option value="28">28</option>
                        <
    option value="29">29</option>
                        <
    option value="30">30</option>
                        <
    option value="31">31</option>
                      </
    select>                </td>
                    <
    td width="56" bgcolor="#eeeeee"><select name="cmbyear" id="cmbyear">
                        <
    option value="2007">2007</option>
                        <
    option value="2006">2006</option>
                        <
    option value="2005">2005</option>
                        <
    option value="2004">2004</option>
                        <
    option value="2003">2003</option>
                        <
    option value="2002">2002</option>
                        <
    option value="2001">2001</option>
                        <
    option value="2000">2000</option>
                        <
    option value="1999">1999</option>
                        <
    option value="1998">1998</option>
                        <
    option value="1997">1997</option>
                        <
    option value="1996">1996</option>
                        <
    option value="1995">1995</option>
                        <
    option value="1994">1994</option>
                        <
    option value="1993">1993</option>
                        <
    option value="1992">1992</option>
                        <
    option value="1991">1991</option>
                        <
    option value="1990">1990</option>
                        <
    option value="1989">1989</option>
                        <
    option value="1988">1988</option>
                        <
    option value="1987">1987</option>
                        <
    option value="1986">1986</option>
                        <
    option value="1985">1985</option>
                        <
    option value="1984">1984</option>
                        <
    option value="1983">1983</option>
                        <
    option value="1982">1982</option>
                        <
    option value="1981">1981</option>
                        <
    option value="1980">1980</option>
                        <
    option value="1979">1979</option>
                        <
    option value="1978">1978</option>
                        <
    option value="1977">1977</option>
                        <
    option value="1976">1976</option>
                        <
    option value="1975">1975</option>
                        <
    option value="1974">1974</option>
                        <
    option value="1973">1973</option>
                        <
    option value="1972">1972</option>
                        <
    option value="1971">1971</option>
                        <
    option value="1970">1970</option>
                        <
    option value="1969">1969</option>
                        <
    option value="1968">1968</option>
                        <
    option value="1967">1967</option>
                        <
    option value="1966">1966</option>
                        <
    option value="1965">1965</option>
                        <
    option value="1964">1964</option>
                        <
    option value="1963">1963</option>
                        <
    option value="1962">1962</option>
                        <
    option value="1961">1961</option>
                        <
    option value="1960">1960</option>
                        <
    option value="1959">1959</option>
                        <
    option value="1958">1958</option>
                        <
    option value="1957">1957</option>
                        <
    option value="1956">1956</option>
                        <
    option value="1955">1955</option>
                        <
    option value="1954">1954</option>
                        <
    option value="1953">1953</option>
                        <
    option value="1952">1952</option>
                        <
    option value="1951">1951</option>
                        <
    option value="1950">1950</option>
                        <
    option value="1949">1949</option>
                        <
    option value="1948">1948</option>
                        <
    option value="1947">1947</option>
                        <
    option value="1946">1946</option>
                        <
    option value="1945">1945</option>
                        <
    option value="1944">1944</option>
                        <
    option value="1943">1943</option>
                        <
    option value="1942">1942</option>
                        <
    option value="1941">1941</option>
                        <
    option value="1940">1940</option>
                        <
    option value="1939">1939</option>
                        <
    option value="1938">1938</option>
                        <
    option value="1937">1937</option>
                        <
    option value="1936">1936</option>
                        <
    option value="1935">1935</option>
                        <
    option value="1934">1934</option>
                        <
    option value="1933">1933</option>
                        <
    option value="1932">1932</option>
                        <
    option value="1931">1931</option>
                        <
    option value="1930">1930</option>
                        <
    option value="1929">1929</option>
                        <
    option value="1928">1928</option>
                        <
    option value="1927">1927</option>
                        <
    option value="1926">1926</option>
                        <
    option value="1925">1925</option>
                        <
    option value="1924">1924</option>
                        <
    option value="1923">1923</option>
                        <
    option value="1922">1922</option>
                        <
    option value="1921">1921</option>
                        <
    option value="1920">1920</option>
                        <
    option value="1919">1919</option>
                        <
    option value="1918">1918</option>
                        <
    option value="1917">1917</option>
                        <
    option value="1916">1916</option>
                        <
    option value="1915">1915</option>
                        <
    option value="1914">1914</option>
                        <
    option value="1913">1913</option>
                        <
    option value="1912">1912</option>
                        <
    option value="1911">1911</option>
                        <
    option value="1910">1910</option>
                        <
    option value="1909">1909</option>
                        <
    option value="1908">1908</option>
                        <
    option value="1907">1907</option>
                        <
    option value="1906">1906</option>
                        <
    option value="1905">1905</option>
                        <
    option value="1904">1904</option>
                        <
    option value="1903">1903</option>
                        <
    option value="1902">1902</option>
                        <
    option value="1901">1901</option>
                        <
    option value="1900">1900</option>
                      </
    select>                </td>
                  </
    tr>
                </
    table>
                <
    br>
                <
    p align="center"
                  <
    input type="checkbox" value="0" height="100"width="100" id="agree" name="C1" style="width: 25; height: 25; border-style: solid; border-width: 0px; padding: 4px">
                  <
    class="watch_bigsmed">I have read and agree to the <a href="terms.php">Terms of Service</aof $url</font></b><br>
          <
    br>
          <
    input type="submit" class= "smallblack" value="Accept and Continue">
          <
    br><br/>
          <
    a href="http://www.google.com" class="smallgreen">do not agree or I am not over 21 years of age.</a>
              </
    FORM>
                </
    td>
        </
    tr></table>
        <
    br/><div align="center"><span class="footmsg"></a> <a href="terms.php" target="_self">Terms of Service</a>&nbsp;&nbsp; |&nbsp;&nbsp; <a href="mailto:i$url">Contact Us</a><br/>
        <
    span class="deep_gray_ragular">Copyright &copy2006-2007 <a href="$url"><span class="style5"All rights reserved.</span><br>
        <
    br>
          <
    a href='http://www.rtalabel.org'><img src='http://www.rtalabel.org/images/120x60_RTA_b.gif' style='border-style: none'/></a>
          </
    span>    </div>
    </
    div>
    </
    body>
    </
    html

    This is the page I do not want users to view without first agreeing.

    PHP Code:
    <?php

    session_start
    ();

    include(
    "include/config.php");

    include(
    "include/function.php");

    if (
    $config['approve'] == 1) {$active "and active = '1'";}

    if (
    $_SESSION['lang'] == ""){
      include(
    "language/en.php");
    } else {
      include(
    "language/".$_SESSION['lang'].".php");
    }  


    # Find the vote information 

    $mydatedate('Y-m-d');

    $sql ="select * from poll_question  where start_date<='$mydate' and end_date>='$mydate'";

    $rs $conn->Execute($sql);

    $x=$rs->getarray();

    $list=explode("|"$x[0]['poll_answer']);

    $sql_members "select * FROM signup";
    $rs_members $conn->execute($sql_members);
    $members $rs_members->getrows();

    STemplate::assign('members_total'count($members));

    $sql_vids "select * FROM video";
    $rs_vids $conn->execute($sql_vids);
    $vids $rs_vids->getrows();

    STemplate::assign('total_vids'count($vids));

    $sql_latesmember "select username, UID from signup order by addtime desc";
    $rs_latesmember $conn->execute($sql_latesmember);
    $latesmember $rs_latesmember->getrows();

    STemplate::assign('latestmember'$latesmember);



            
    $sql "SELECT sum(viewnumber) as total from video";
            
    $ars $conn->Execute($sql);
            
    STemplate::assign('vviews'number_format($ars->fields['total'],0,",",".")); 

    //PAGING

    $items_per_page=($config[rows_per_page]*$config[cols_per_page]);

    $sql="SELECT * from video where type='public' and featured='yes' $active order by addtime desc";

    $rs $conn->Execute($sql);

    if(
    $rs->recordcount()>0)$users $rs->getrows();

    //END PAGING


    //PAGING
    $sql="SELECT * from channel";
    $rs $conn->Execute($sql);
    $indexchannel $rs->getrows();
    //END PAGING

    STemplate::assign('channelanswers',$indexchannel);


















    $sql1 "select * from video where type='public' $active order by addtime desc"

    $rs_v $conn->execute($sql1);

    $recent $rs_v->getrows();

    STemplate::assign('recent'$recent);

    STemplate::assign('recent_total'count($recent));



    if (
    $_REQUEST[msg]!=""){

        
    $msg=$_REQUEST[msg];

    }



    STemplate::assign('err',$err);

    STemplate::assign('msg',$msg);

    STemplate::assign('answers',$users);

    STemplate::assign('total',$rs->recordcount());

    $featuredtagsquery="SELECT keyword from video where type='public' $active order by viewnumber desc limit 20";
            
    $tagshome=cloudTags($featuredtagsquery);
            
    STemplate::assign('tagshome',$tagshome);



    if(
    $config['enable_package']=="yes" and $_SESSION[UID]!="")

    {

            
    $sql "select * from subscriber where UID=$_SESSION[UID]";

            
    $rs $conn->execute($sql);

            
    $u_info $rs->getrows();

            
    STemplate::assign('u_info'$u_info[0]);

            
    $rs->movefirst();

            

            
    $sql "select * from package where pack_id=".$rs->fields['pack_id'];

            
    $rs $conn->execute($sql);

            
    $pack $rs->getrows();

            
    STemplate::assign('pack'$pack[0]);

    }



    STemplate::display('head1.tpl');

    STemplate::display('err_msg.tpl');

    STemplate::display('index.tpl');

    STemplate::display('footer.tpl');

    ?>
    Last edited by firepages; 09-03-2007 at 04:02 AM. Reason: removed link

  • #15
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    OK, index.htm is going to have to be index.php. You'll need to make this a php page to start the session. At the start of your php, you'll need:

    PHP Code:
    session_start()
    $_SESSION['view_video'] = true
    That starts a session and adds a session variable named 'view_video' (you can change this) to 'true';


    Then for the view video page, add the part in red:

    Code:
    <?php
    
    session_start();
    
    if ( !isset($_SESSION['view_video']) || $_SESSION['view_video'] == false )
    {
       header('Location: index.php');
    }
    That will check to see if the session variable is set correctly, and redirect if not.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •