Jump to content
xisto Community
Sign in to follow this  
hitmanblood

Passing Values By Get

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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:

<?$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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

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

Share this post


Link to post
Share on other sites

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 Xisto servers and try to use post method, hopefully it will work.

Share this post


Link to post
Share on other sites

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

<?phpphpinfo();?>

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Don't forget that the form variables need to be "submitted" before they contain values. Before the form is correctly submitted, the variables would be initiallized as NULL.

Share this post


Link to post
Share on other sites

Don't forget that the form variables need to be "submitted" before they contain values. Before the form is correctly submitted, the variables would be initiallized as NULL.

Well I am aware of that fact and in fact I have some form variables which are chosen from the list so there is no way that they wouldn't get initialized. The main problem is between form connection and my php script as I see it.

Share this post


Link to post
Share on other sites

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.. ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.