SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: get variables

  1. #1
    SitePoint Evangelist jor133d's Avatar
    Join Date
    Jul 2003
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    get variables

    I am trying to get some help with using the get variable.

    I have an if statement on one page that says if the SQL statement worked, display yes, and if the SQL statement fail send no.

    I want to use these yes or no variable values on another page. How do I use the get variable to send across pages?

  2. #2
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there r two ways to do that:
    using a form or send through url.
    if u r using the form then method will be GET not post.
    And on the other page retrieve it like:
    $name=trim($_GET['name']);
    Remember u have to pass name in the form like:
    <input name='name' value=''>{something like this}

    Now url:
    This url will be used in ur scripts to redirect user to another page like using header etc.
    http://localhost/site/script.php?name='$name'.
    And on the other page retrieve it like:
    $name=trim($_GET['name']);

    Hope this will help.

  3. #3
    SitePoint Evangelist jor133d's Avatar
    Join Date
    Jul 2003
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes it is very helpful!

    But...

    The url way would work the best for my problem, how do you send something in the url?

  4. #4
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lets take an example here:

    ur sql query runs and on YES it will redirect user to another page like:

    $sql1="select * from table where name='$username' ";
    $sql=mysql_query($sql1);
    $row=mysql_fetch_object($sql);
    $name=$row->username;
    if($sql){header ('location:http://localhost/site/script.php?name="$name"');}
    else {echo "error notice";}

    It will redirect user to another page with name variable in url,and there u can access it by using GET,which i show in above post.

  5. #5
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jor133d View Post
    Yes it is very helpful!

    But...

    The url way would work the best for my problem, how do you send something in the url?
    how about this:
    PHP Code:
    $sql "SELECT * FROM tablename";
    $result mysql_query($sql) or die(mysql_error());
    if(
    $result)
        
    $flag "Yes";
    else
        
    $flag "No";
    header("Location: http://www.yoursite.com/redirectingpage.php?flag=" $flag);
    exit(); 
    Last edited by Raju Gautam; Dec 10, 2007 at 00:50.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  6. #6
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,561
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jor133d
    I am trying to get some help with using the get variable.

    I have an if statement on one page that says if the SQL statement worked, display yes, and if the SQL statement fail send no.

    I want to use these yes or no variable values on another page. How do I use the get variable to send across pages
    I wonder what could be the purpose for doing all this. The values you are trying to send to the other page can easily be tempered. So you'd better use something like session.


Bookmarks

Posting Permissions

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