Jul 24, 2008

Passing Values By Get

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming
Pages: 1, 2

free web hosting

Passing Values By Get

hitmanblood
I have problem I've been doing some programming in php that is something similar to registration but whenever I want to check something it seems like variables are not passed or that the php variables are empty I am using get instead of post however I am also considering to switch to post as I cannot find an error. Anyone had similar experience that he could help me? Thanks in advance.

Reply

shadowx
Is there any chance we can see the code you are using in php and the form code you have used, that would in HTML.

Im thinking maybe youve made a little error in the php or on the form. The two things to check are that in php you do something like:

CODE
<?
$var = $_GET['var'];

echo $var;
?>


Of course you can do more then ECHO but i usually do that to make my variables easier to manage, the most important bit is $_GET['var']; make sure you have that exactly the same in your scripts, of course change "var" to the variable name. I sometimes forget the underscore and thats never pretty!

And on the form make sure you have the "action=" correctly set and the "method=GET" set also. I sometimes write POST on the form and GET in my php and such. Again, thats not very effective!

Though if this doesnt solve it then post the part of the php code that gets the GET variables and someone should be able to see if anything is wrong.

 

 

 


Reply

hitmanblood
Well OK here it is I will put just parts of code.

The beggining of the form:

<form action="private/submition.php" method="GET">


Then parts where php script obtians variables values.

$username = $_GET['username'];

$rank = $_GET['rank'];

$email = $_GET['email'];

$link = $_GET['link'];

Some variables. I really don't see possible mistake as I hvae done this thousand times and now in this particula script it doesn't dowrk.

Also I have script on the same server which works with input and it works fine without any problem.

Reply

Blessed
Greetings

if you want to use the $_GET function the variable you want to get most be in the url
lik
www.mypage.com?index=your van value

now to get that value us

$myvalue = $_GET['index'];

simple as that

you can use more than one var in one link
like this

www.mypage.com?index=value1&var2=var2value&var3=value3

Have fun with it

Reply

shadowx
Well the code looks fine to me too!

As Blessed said the variables should be in the URL s check that they are in the URL, if they are then presumably the problem is in the php, if they arent in the URL then it presumably resides in the HTML somewhere.

I was going to suggest that it could be something in the settings file or some configuration on the server but you mentioned that other scripts work so its unlikely to be that.

Reply

hitmanblood
Well I don't see the problem it kinda eludes me because whenever I try to echo the variable value it is just not there.

Is there maybe some kinda of rule for too many variables passed.

Reply

matak
QUOTE(hitmanblood @ Apr 15 2007, 08:44 PM) *
Well I don't see the problem it kinda eludes me because whenever I try to echo the variable value it is just not there.

Is there maybe some kinda of rule for too many variables passed.


I found this code works just fine

CODE
<form method="GET">
Username: <input type="text" name="username"><br>
Rank: <input type="text" name="rank"><br>
Email: <input type="text" name="email"><br>
Link: <input type="text" name="link"><br>
<input type="submit" value="Process">
</form>


<?php

$username = $_GET['username'];

echo $username.'<br>';

$rank = $_GET['rank'];

echo $rank.'<br>';

$email = $_GET['email'];

echo $email.'<br>';

$link = $_GET['link'];

echo $link.'<br>';

?>


I really don't know what is your problem, but you could post your full script, with errors if you have any. Also for form submition i would recommend using PHP $_POST instead of $_GET.

Reply

hitmanblood
Well yes I know but on the previous server where I tested this script post method was not allowed so I had to use get. And If I try to echo those variables I get just blank spot. So the problem is not in the rest of the script rather in the passing itself.

I will also try to switch to the trap17 servers and try to use post method, hopefully it will work.

Reply

matak
QUOTE(hitmanblood @ Apr 16 2007, 12:36 AM) *
Well yes I know but on the previous server where I tested this script post method was not allowed so I had to use get. And If I try to echo those variables I get just blank spot. So the problem is not in the rest of the script rather in the passing itself.

I will also try to switch to the trap17 servers and try to use post method, hopefully it will work.


sure sounds like PHP problem if you tested this script. try running phpinfo on your hosting provider to see the version of PHP they are using. then you should check for compatibility of your code with the version of PHP used at your hosting. i suggest that you use trap17 hosting couse it uses PHP 5.2 which is much better than older versions.

Runing phpinfo on your site can be done by you creating info.php file and putting this code inside

CODE
<?php

phpinfo();

?>

Reply

hitmanblood
Thanks matak but I know that and the weird thing is that I have similar script working on that server it is just that this one doesn't want to work. I still cant figure why. But as I am considering to transfer all my work to this host I will check it again and then inform if I have any further problems.

Reply

Latest Entries

matak
QUOTE(hitmanblood @ Apr 16 2007, 09:50 PM) *
I am not really keen on reveling my code however when I try to echo or print variables after GET methods none of them will show up. That means that it is not problem somewhere later on in the script bu rather in the passing variable value to the php script from the html form.


ok i understand that you don't wont to reveal your code. but then again you need to understand that it is really hard for anyone to guess what is wrong with your script when you don't want to show it. i honestly don't belive that you wrote code that is so much valuable so that it can't be shown. maybe your script is full of usernames and passwords which you can't publish, so that would make sense... anyway, i hope that transfering to trap17 and PHP 5 will do the trick wink.gif

Reply

hitmanblood
QUOTE(matak @ Apr 16 2007, 07:01 PM) *
well hitmanblood, you didn't post any of your code. in order for anyone to help, you should post both your PHP and HTML code here so that we can see what's the problem more easily. also use code tags to wrap code.. smile.gif


I am not really keen on reveling my code however when I try to echo or print variables after GET methods none of them will show up. That means that it is not problem somewhere later on in the script bu rather in the passing variable value to the php script from the html form.

Reply

matak
QUOTE(hitmanblood @ Apr 16 2007, 06:26 PM) *
Check the first page.


well hitmanblood, you didn't post any of your code. in order for anyone to help, you should post both your PHP and HTML code here so that we can see what's the problem more easily. also use code tags to wrap code.. smile.gif

Reply

hitmanblood
QUOTE(Blessed @ Apr 16 2007, 01:48 PM) *
can you post your code so i can see it


Check the first page.

Reply

Blessed
can you post your code so i can see it

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Similar Topics

Keywords : passing, values

  1. Php An Js Window.open Pages Trouble.
    I need a way to set hidden input values to the new window. (3)
  2. [php](simple) Using Functions To Combine Values In A Form
    Really simple example on how to combine values with function (2)
    I just learned this simple method on how to use functions to combine two values from a form. First
    we create ourselves a simple POST form CODE <form method="POST"> Name:
    <input type="text" name="nickname"> Location: <input
    type="text" name="location"> <input type="submit"
    value="Input"> </form> Now we add this php to that same file CODE
    <?php $nick = $_POST['nickname']; $location =
    $_POST['location' ....
  3. Include And Values
    (3)
    hi everybody, i am new to php programming, i have this code in page number 1: CODE <?php
        $pages = array(                 'number1' => 'number1.php',
        'number2' => 'number2.php',     'number3' =>
    'number3.php',                 'number4' => 'number4.php',
            );             if (isset($_GET['page']) &&
    isset($pages[$_GET['page']]))                 {
                        include(....
  4. Converting Characters In A Variable To Individual Values In An Array
    turning variables into arrays (2)
    Say I have a variable such as $nav_item and it had to contents Home . IE: CODE
    $nav_item = 'Home'; How would I make so that $nav_item was an array and
    had the following contents? CODE $nav_item = array ('h', 'o',
    'm', 'e'); With the case changing (ie H would become h and U
    would become u ) EDIT: Okay found out that I could change the case with
    array_change_key_case ($nav_item, CASE_LOWER); ....

    1. Looking for passing, values

Searching Video's for passing, values
advertisement



Passing Values By Get



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE