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 22
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts

    is it possible to use the header option to send the user to the previous page?

    basically as the title says,

    i have a form which i want to submit to the previous page if the user has entered the correct data and to display errors if the data is not correct.

    i also would like to know how to make the errors appear underneath the input box instead of at the top of my page?

    here is the page

    and here is the code
    PHP Code:
    <?php 
    session_start
    ();
    ini_set('display_errors',1);
    ini_set('display_startup_errors',1);
    error_reporting(E_ALL);
    require(
    'functions.php'); 
    require(
    '_drawrating.php');
    include_once(
    'db101.php');?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Kernow Connect</title>
    <link rel="stylesheet" type="text/css" href="stylesheets/common_stylesheet.css" />
    <link rel="stylesheet" type="text/css" href="stylesheets/stores_stylesheet.css" />
    <link rel="stylesheet" type="text/css" href="css/rating.css" />

    <script type="text/javascript" language="javascript" src="js/behavior.js"></script>
    <script type="text/javascript" language="javascript" src="js/rating.js"></script>

    </script>

    <style type="text/css">
    <!--
    .apDiv1 {
        width:200px;
        height:115px;
        float:left;
    }
    body {
        background-image: url(images/background.jpg);
        background-repeat: repeat-y;
        background-position:center;
        }
    </style>

    <body>

    <?php 


    //Database info included in include

    Toplinks();
    print 
    "<br /><br />";



    ?>
    <div id="subcontent" style="background-color:#FCE08B; width: 900px; height:361px; padding: 8px; margin:0 auto;">
    <?php
    $message101
    ="";
    if( isset(
    $_POST['submit'])) {
        If (empty(
    $_POST['security_code']))
        {
        
    $errors[] = 'Please enter the security code';
        }
        
       if( 
    $_SESSION['security_code'] <> $_POST['security_code']) {
       
    $errors[] = 'Please enter the correct security code';
        }
        
        if (
    count($errors) == 0)
        {
            
    // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. 
            
    $sql="UPDATE ratings 
      SET 
        used_ips = NULL,
        total_value = 0,
        total_votes = 0 
      WHERE 
      id IN ('valuetemp', 'easeofusetemp', 'deliverytemp', 'delchargetemp')"
    ;
      
    $query mysql_query($sql);
      
    //header('index.php');

            
    unset($_SESSION['security_code']);
       }
         
        else {
        
    //debug
        
    echo "<font color='red'>".count($errors)." Error(s) found! <br></font>";
        {
        
    //echo $errors[0];
         
    echo "<font color='#A66300'>";
         echo 
    "<ul>";
         foreach(
    $errors as $error)
             echo 
    "<li>$error</li>";
         echo 
    "</ul>";
         print 
    "</font>";
        }
    }
            
    // Insert your code for showing an error message here
       
    }
    ?>  

    <form method="post" action="rate.php">
        <div id="apDiv1">
        <table width="250" border="0" align="left" cellpadding="0" cellspacing="0">
          <tr>
            <td>Value for money</span></td>
            <td><span class="storeRatings_Individual"><?php print rating_bar('valuetemp',5);?></span></td>
          </tr>
          <tr>
            <td>Ease of use</span></td>
            <td><span class="storeRatings_Individual"><?php print rating_bar('easeofusetemp',5);?></span></td>
          </tr>
          <tr>
            <td>Delivery time</span></td>
            <td><span class="storeRatings_Individual"><?php print rating_bar('deliverytemp',5);?></span></td>
          </tr>
          <tr>
            <td>P&amp;P costs</span></td>
            <td><span class="storeRatings_Individual"><?php print rating_bar('delchargetemp',5);?></span></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" /></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td colspan="2"><label for="label"><span class="style2">Please Enter Security Code: </span></label></td>
          </tr>
          <tr>
            <td colspan="2"><input id="security_code" name="security_code" type="text" /></td>
          </tr>
          <tr>
            <td><?php echo $message101 ?></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input type="submit" name="submit" value="Submit" />
            </td>
            <td></td>
          </tr>
        </table>
      </form>
      <p> 
    </div>
    </body>
    </html>
    all help welcomed
    cheers

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Just move all your PHP validation parts to the top of your page(before DOCTYPE).
    After that add a small change to your validation part, like
    PHP Code:
    If (empty($_POST['security_code']))
        {
        
    $errors['sec_code'] = 'Please enter the security code';
        }
        
       if( 
    $_SESSION['security_code'] <> $_POST['security_code']) {
       
    $errors['sec_code'] = 'Please enter the correct security code';
        } 
    , which will help you track the errors easily(even with a large form with mnay elements)
    Now change
    PHP Code:
    if (count($errors) == 0)
        {
            
    // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. 
            
    $sql="UPDATE ratings 
      SET 
        used_ips = NULL,
        total_value = 0,
        total_votes = 0 
      WHERE 
      id IN ('valuetemp', 'easeofusetemp', 'deliverytemp', 'delchargetemp')"
    ;
      
    $query mysql_query($sql);
      
    //header('index.php');

            
    unset($_SESSION['security_code']);
       }
         
        else {
        
    //debug
        
    echo "<font color='red'>".count($errors)." Error(s) found! <br></font>";
        {
        
    //echo $errors[0];
         
    echo "<font color='#A66300'>";
         echo 
    "<ul>";
         foreach(
    $errors as $error)
             echo 
    "<li>$error</li>";
         echo 
    "</ul>";
         print 
    "</font>";
        }

    to something like
    PHP Code:
    if (count($errors) == 0)
        {
            
    // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. 
            
    $sql="UPDATE ratings 
      SET 
        used_ips = NULL,
        total_value = 0,
        total_votes = 0 
      WHERE 
      id IN ('valuetemp', 'easeofusetemp', 'deliverytemp', 'delchargetemp')"
    ;
      
    $query mysql_query($sql);
      unset(
    $_SESSION['security_code']); // not sure about the purpose
       
    header('next_page.php'); // substitute with the right url 

            
       

    Now just above your form, add
    PHP Code:
    if(count($errors)) {
        
    //debug
        
    echo "<font color='red'>".count($errors)." Error(s) found! <br></font>";
       } 
    Then add the code to echo the error near to your input element like
    PHP Code:
    <td colspan="2"><input id="security_code" name="security_code" type="text" /><?php
    if(isset($errors['sec_code']))
       echo 
    $errors['sec_code'];
    ?></td>
    PS: Know how to make an accessible form without table
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    LJackson (03-11-2009)

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    hi mate this looks promising

    i have corrected it like you suggested and it partially works,

    however i am currntly getting a notice:
    Notice: Undefined index: security_code in /customers/kernow-connect.com/kernow-connect.com/httpd.www/rate.php on line 42

    and the error report is showing as soon as the page is displayed not after the submit button is pressed?

    do i need to add in
    PHP Code:
    if(isset($_POST['submit'])){ 
    before
    PHP Code:
    If (empty($_POST['security_code']))
        {
        
    $errors['sec_code'] = 'Please enter the security code';
        }
        
       if( 
    $_SESSION['security_code'] <> $_POST['security_code']) {
       
    $errors['sec_code'] = 'Please enter the correct security code';
        } 
    cheers mate
    Luke

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    Ok i have managed to get rid of the error messages at the page start up by adding

    PHP Code:
    if(isset($_POST['submit'])){ 
    to the relivant pieces of code but i am still getting

    Code:
    Notice: Undefined index: security_code in /customers/kernow-connect.com/kernow-connect.com/httpd.www/rate.php on line 43
    line 43 is
    PHP Code:
    if( $_SESSION['security_code'] <> $_POST['security_code']) { 
    any ideas how to solve this?

    many thanks
    Luke
    Last edited by LJackson; 03-10-2009 at 06:58 PM.

  • #5
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    where is $_SESSION['security_code'] set?

  • #6
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    hi ohgod,

    good question?

    ah found it its in another file CaptchaSecurityImages.php.
    PHP Code:
    <?php
    session_start
    ();

    /*
    * File: CaptchaSecurityImages.php
    * Author: Simon Jarvis
    * Copyright: 2006 Simon Jarvis
    * Date: 03/08/06
    * Updated: 07/02/07
    * Requirements: PHP 4/5 with GD and FreeType libraries
    * Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php

    * This program is free software; you can redistribute it and/or 
    * modify it under the terms of the GNU General Public License 
    * as published by the Free Software Foundation; either version 2 
    * of the License, or (at your option) any later version.

    * This program is distributed in the hope that it will be useful, 
    * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    * GNU General Public License for more details: 
    * http://www.gnu.org/licenses/gpl.html
    *
    */

    class CaptchaSecurityImages {

        var 
    $font 'monofont.ttf';

        function 
    generateCode($characters) {
            
    /* list all possible characters, similar looking characters and vowels have been removed */
            
    $possible '23456789bcdfghjkmnpqrstvwxyz';
            
    $code '';
            
    $i 0;
            while (
    $i $characters) { 
                
    $code .= substr($possiblemt_rand(0strlen($possible)-1), 1);
                
    $i++;
            }
            return 
    $code;
        }

        function 
    CaptchaSecurityImages($width='120',$height='40',$characters='6') {
            
    $code $this->generateCode($characters);
            
    /* font size will be 75% of the image height */
            
    $font_size $height 0.75;
            
    $image = @imagecreate($width$height) or die('Cannot initialize new GD image stream');
            
    /* set the colours */
            
    $background_color imagecolorallocate($image255255255);
            
    $text_color imagecolorallocate($image2040100);
            
    $noise_color imagecolorallocate($image100120180);
            
    /* generate random dots in background */
            
    for( $i=0$i<($width*$height)/3$i++ ) {
                
    imagefilledellipse($imagemt_rand(0,$width), mt_rand(0,$height), 11$noise_color);
            }
            
    /* generate random lines in background */
            
    for( $i=0$i<($width*$height)/150$i++ ) {
                
    imageline($imagemt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
            }
            
    /* create textbox and add text */
            
    $textbox imagettfbbox($font_size0$this->font$code) or die('Error in imagettfbbox function');
            
    $x = ($width $textbox[4])/2;
            
    $y = ($height $textbox[5])/2;
            
    imagettftext($image$font_size0$x$y$text_color$this->font $code) or die('Error in imagettftext function');
            
    /* output captcha image to browser */
            
    header('Content-Type: image/jpeg');
            
    imagejpeg($image);
            
    imagedestroy($image);
            [
    COLOR="Red"][B]$_SESSION['security_code'] = $code;[/B][/COLOR]
        }

    }

    $width = isset($_GET['width']) ? $_GET['width'] : '120';
    $height = isset($_GET['height']) ? $_GET['height'] : '40';
    $characters = isset($_GET['characters']) && $_GET['characters'] > $_GET['characters'] : '6';

    $captcha = new CaptchaSecurityImages($width,$height,$characters);

    ?>
    and its called on my page using this code
    PHP Code:
    <img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" alt='security image' /> 

  • #7
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    ok i have had to go back a few steps as i ran into some difficultys

    im back to where abduraooft provided the code above

    and as the page loads all the errors and messages show up e.g incorrect code etc and im still getting
    PHP Code:
    NoticeUndefined indexsecurity_code in /customers/kernow-connect.com/kernow-connect.com/httpd.www/rate.php on line 15 
    if i enter the incorred validation i get the correct messages show as id expect

    and if i enter the correct validation and submit the form i get a few errors appear
    Code:
    Notice: Undefined variable: errors in /customers/kernow-connect.com/kernow-connect.com/httpd.www/rate.php on line 62
    
    Warning: Cannot modify header information - headers already sent by (output started at /customers/kernow-connect.com/kernow-connect.com/httpd.www/rate.php:26) in /customers/kernow-connect.com/kernow-connect.com/httpd.www/rate.php on line 74
    
    Notice: Undefined variable: errors in /customers/kernow-connect.com/kernow-connect.com/httpd.www/rate.php on line 79
    not sure how to solve

    here is the page

    here is the code for my page
    PHP Code:
    <?php 
    session_start
    ();
    ini_set('display_errors',1);
    ini_set('display_startup_errors',1);
    error_reporting(E_ALL);
    require(
    'functions.php'); 
    require(
    '_drawrating.php');
    include_once(
    'db101.php');

    If (empty(
    $_POST['security_code']))
        {
        
    $errors['sec_code'] = 'Please enter the security code';
        }
        
       if( 
    $_SESSION['security_code'] <> $_POST['security_code']) {
       
    $errors['sec_code'] = 'Please enter the correct security code';
        }
        
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Kernow Connect</title>
    <link rel="stylesheet" type="text/css" href="stylesheets/common_stylesheet.css" />
    <link rel="stylesheet" type="text/css" href="stylesheets/stores_stylesheet.css" />
    <link rel="stylesheet" type="text/css" href="css/rating.css" />

    <script type="text/javascript" language="javascript" src="js/behavior.js"></script>
    <script type="text/javascript" language="javascript" src="js/rating.js"></script>

    </script>

    <style type="text/css">
    <!--
    .apDiv1 {
        width:200px;
        height:115px;
        float:left;
    }
    body {
        background-image: url(images/background.jpg);
        background-repeat: repeat-y;
        background-position:center;
        }
    </style>
    <?php
    print "<body>";


    //Database info included in include

    Toplinks();
    print 
    "<br /><br />";



    ?>
    <div id="subcontent" style="background-color:#FCE08B; width: 900px; height:361px; padding: 8px; margin:0 auto;">
    <?php

    if (count($errors) == 0)
        {
            
    // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. 
            
    $sql="UPDATE ratings 
      SET 
        used_ips = NULL,
        total_value = 0,
        total_votes = 0 
      WHERE 
      id IN ('valuetemp', 'easeofusetemp', 'deliverytemp', 'delchargetemp')"
    ;
      
    $query mysql_query($sql);
      unset(
    $_SESSION['security_code']); // not sure about the purpose
       
    header('index.php'); // substitute with the right url 

            
       
    }  
       
        if(
    count($errors)) {
        
    //debug
        
    echo "<font color='red'>".count($errors)." Error(s) found! <br></font>";
           }     
    ?>  

    <form method="post" action="rate.php">
        <div id="apDiv1">
        <table width="250" border="0" align="left" cellpadding="0" cellspacing="0">
          <tr>
            <td>Value for money</span></td>
            <td><span class="storeRatings_Individual"><?php print rating_bar('valuetemp',5);?></span></td>
          </tr>
          <tr>
            <td>Ease of use</span></td>
            <td><span class="storeRatings_Individual"><?php print rating_bar('easeofusetemp',5);?></span></td>
          </tr>
          <tr>
            <td>Delivery time</span></td>
            <td><span class="storeRatings_Individual"><?php print rating_bar('deliverytemp',5);?></span></td>
          </tr>
          <tr>
            <td>P&amp;P costs</span></td>
            <td><span class="storeRatings_Individual"><?php print rating_bar('delchargetemp',5);?></span></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" alt='security image' /></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td colspan="2"><label for="label"><span class="style2">Please Enter Security Code: </span></label></td>
          </tr>
          <tr>
            <td colspan="2"><input id="security_code" name="security_code" type="text" /></td>
          </tr>
          <tr>
            <td><?php 
            
    if(isset($errors['sec_code']))
               echo 
    $errors['sec_code'];
            
    ?> </td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input type="submit" name="submit" value="Submit" />
            </td>
            <td></td>
          </tr>
        </table>
      </form>
      <p> 
    </div>
    </body>
    </html>
    and my CaptchaSecurityImages.php page code
    PHP Code:
    <?php
    session_start
    ();

    /*
    * File: CaptchaSecurityImages.php
    * Author: Simon Jarvis
    * Copyright: 2006 Simon Jarvis
    * Date: 03/08/06
    * Updated: 07/02/07
    * Requirements: PHP 4/5 with GD and FreeType libraries
    * Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php

    * This program is free software; you can redistribute it and/or 
    * modify it under the terms of the GNU General Public License 
    * as published by the Free Software Foundation; either version 2 
    * of the License, or (at your option) any later version.

    * This program is distributed in the hope that it will be useful, 
    * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    * GNU General Public License for more details: 
    * http://www.gnu.org/licenses/gpl.html
    *
    */

    class CaptchaSecurityImages {

        var 
    $font 'monofont.ttf';

        function 
    generateCode($characters) {
            
    /* list all possible characters, similar looking characters and vowels have been removed */
            
    $possible '23456789bcdfghjkmnpqrstvwxyz';
            
    $code '';
            
    $i 0;
            while (
    $i $characters) { 
                
    $code .= substr($possiblemt_rand(0strlen($possible)-1), 1);
                
    $i++;
            }
            return 
    $code;
        }

        function 
    CaptchaSecurityImages($width='120',$height='40',$characters='6') {
            
    $code $this->generateCode($characters);
            
    /* font size will be 75% of the image height */
            
    $font_size $height 0.75;
            
    $image = @imagecreate($width$height) or die('Cannot initialize new GD image stream');
            
    /* set the colours */
            
    $background_color imagecolorallocate($image255255255);
            
    $text_color imagecolorallocate($image2040100);
            
    $noise_color imagecolorallocate($image100120180);
            
    /* generate random dots in background */
            
    for( $i=0$i<($width*$height)/3$i++ ) {
                
    imagefilledellipse($imagemt_rand(0,$width), mt_rand(0,$height), 11$noise_color);
            }
            
    /* generate random lines in background */
            
    for( $i=0$i<($width*$height)/150$i++ ) {
                
    imageline($imagemt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
            }
            
    /* create textbox and add text */
            
    $textbox imagettfbbox($font_size0$this->font$code) or die('Error in imagettfbbox function');
            
    $x = ($width $textbox[4])/2;
            
    $y = ($height $textbox[5])/2;
            
    imagettftext($image$font_size0$x$y$text_color$this->font $code) or die('Error in imagettftext function');
            
    /* output captcha image to browser */
            
    header('Content-Type: image/jpeg');
            
    imagejpeg($image);
            
    imagedestroy($image);
            
    $_SESSION['security_code'] = $code;
        }

    }

    $width = isset($_GET['width']) ? $_GET['width'] : '120';
    $height = isset($_GET['height']) ? $_GET['height'] : '40';
    $characters = isset($_GET['characters']) && $_GET['characters'] > $_GET['characters'] : '6';

    $captcha = new CaptchaSecurityImages($width,$height,$characters);

    ?>
    any ideas where to go next???

    thank you
    Luke

  • #8
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    hi all,

    ok i think im getting somewhere

    im still getting that bl**dy notice when the page first loads
    Code:
    Notice: Undefined index: security_code in /customers/kernow-connect.com/kernow-connect.com/httpd.www/rate.php on line 18
    but i have managed to get the form to redirect to another page when submitted correctly and to display an error if not,

    not sure how to get rid of that notice tho
    any ideas
    Luke

  • #9
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    A slight modification to:
    PHP Code:
    if( $_SESSION['security_code'] <> $_POST['security_code']) {
       
    $errors['sec_code'] = 'Please enter the correct security code';
        } 
    Check to see if the variable is set ...
    PHP Code:
    if( empty($_POST['security_code']) || $_SESSION['security_code'] <> $_POST['security_code']) {
       
    $errors['sec_code'] = 'Please enter the correct security code';
        } 
    This will display the error if the user enters the wrong security code, or no security code at all.
    John

  • Users who have thanked PappaJohn for this post:

    LJackson (03-11-2009)

  • #10
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    hi pappajohn,

    that seems to have solved it
    thank you.

    on to the next problems...
    i would like my page to redirect to the previous page which may be tricky as its not just a simple page but it had varibles passed to it to display the correct page, how do i pass those varibles again to ensure i get sent to that page.

    e,g
    the typical page would be
    http://www.kernow-connectcom/teststo...t=ent&sID=Game

    which has a link to the rate page which is the page ive just been working on where the user can rate that store then if all is correct the page sends the user back to where they were.

    the original varible values are sent from entertainment.php -> teststores.php and then i want it passed on to ->rate.php and then stores.php
    Last edited by LJackson; 03-11-2009 at 12:16 PM.

  • #11
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    A standard header() redirect will still work.

    Something along these lines:
    PHP Code:
    $page 'teststores.php';
    $cat 'ent';
    $id 'Game';

    header('Location: ' $page '?Cat=' $cat '&sID=' $id);
    exit(); 
    Edit: corrected typo
    Last edited by PappaJohn; 03-11-2009 at 08:13 PM. Reason: typos
    John

  • #12
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    hi mate,

    the above code only seems to add those varibles to the current address e.g
    http://www(dot)kernow-connect(dot)co...t=ent&sID=Game

    do i need to move the exit(); to the end of my page?

    also this way work for a set value but because my users will be accessing this page from a variety of different pages i need to some how pass on the values from those pages.

    e.g if the user visits the game stores page-> stores.php?Cat=ent&sID=Game, the values are attached so that the page is unique to game,

    so i need to beable to pass those to the rate page and then on to the redirect,

    sorry if this isnt described very well im trying my best lol

    cheers mate

  • #13
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    ok mate forget the first part

    just noticed a small typo in your code $page - 'teststores.php';

    just noticed that straight after i posted above, typical

    so i just need to pass those varibles through about 3 pages to get them to the rate page. any ideas

    cheers mate

  • #14
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Those typos will get you everytime - you'd think I could type by now.

    A couple choices:

    You could pass them as part of the query string from page to page. You'd have to grab them from the $_GET array (as well as sanitizing them) on each page, and then build your link like we did above.

    Or, you could store them in sessions. The first page would grab the variables and create session variables. Each successive page would read the session vars instead of $_GET. (This would be my approach).
    John

  • #15
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,098
    Thanks
    297
    Thanked 12 Times in 12 Posts
    lol...

    as far as which route to take im torn lol
    do some people have sessions turned off or do something to them to stop them working?

    and the get array looks a bit untidy but will prob be safest?

    am i right about the sessions?


  •  
    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
    •