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.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Jul 2009
    Posts
    43
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Alternative to $_get

    I need to pass and display some variables , but some will be longer than 100 characters, what alternative to $_GET can I use?

  • #2
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    $_post

  • #3
    New Coder
    Join Date
    Jul 2009
    Posts
    43
    Thanks
    13
    Thanked 0 Times in 0 Posts
    Hmm, I think my problems go beyond that. Clearly, I can see my what I need passed in the url, but it's not showing on the page when I try echoing out.

  • #4
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    you need to show us what is posting the var and how your echoing the var if you want help.

  • #5
    New Coder
    Join Date
    Jul 2009
    Posts
    43
    Thanks
    13
    Thanked 0 Times in 0 Posts
    Page1.php
    PHP Code:
    <form method="post" action="sendmail.php">
       <input type="text" name="email"/><br />
       <input type="hidden" name="product"  value="<?php echo $row_product['product']; ?>"/>  
                                                                          
      <input type="submit" />
    </form>
    sendmail.php
    PHP Code:
     $email $_REQUEST['email'] ;
      
    $product=$_REQUEST['product'];
    $recipients "test@gmail.com";

      
    $message="
      Request From: $email
      Interested In:  $product
      
      "
    ;
     
      
    mail"$recipients""$email Needs  "$message "From: $email " );
      
      
    header("location:results.php?email=$email&product=$product"); 
    results.php page
    PHP Code:
    <?php echo $_GET['product']; ?>

    Plus this page has a lot of other garbage such as parts of an xcart script etc...
    Everything works fine up until the last page where I see the 'product' variable in the URL but it doesn't echo out. It is a fairly long url, don't know if that's the issue.

  • #6
    New Coder
    Join Date
    Aug 2009
    Posts
    26
    Thanks
    1
    Thanked 3 Times in 3 Posts
    there are other variables you can use alternative to $_GET
    $_POST
    $_COOKIE (can be set only once per page)
    $_SESSION

  • #7
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    Those requests need to be posts.
    PHP Code:
     $email $_POST['email'] ; 
      
    $product=$_POST['product']; 
    $recipients "test@gmail.com"

      
    $message=
      Request From: $email 
      Interested In:  $product 
       
      "

      
      
    mail"$recipients""$email Needs  "$message "From: $email " ); 
       
      
    header("location:results.php?email=$email&product=$product"); 

  • Users who have thanked seco for this post:

    GenVic (08-25-2009)

  • #8
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Quote Originally Posted by seco View Post
    Those requests need to be posts.
    In case you're (GenVic) confused as to why, its because the form is using the post method:

    <form method="post">

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • Users who have thanked whizard for this post:

    GenVic (08-25-2009)

  • #9
    New Coder
    Join Date
    Jul 2009
    Posts
    43
    Thanks
    13
    Thanked 0 Times in 0 Posts
    Thanks guys, that did it.


  •  

    Posting Permissions

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