Jump to content

opening page with GET and POST


melting_dog

Recommended Posts

Hi all,

 

I have a page that runs a query where users can send info via either a form (post) or from redirecting from another page (get).

 

The get function uses:

header("location:forumsDiscussion.php?$comDiscussNo");

to send content of the $comDiscussNo variable and appears to work fine: i can see the variable content in the URL.

 

but when i put these into if statements it doesnt run.

Heres the code:

 

<?php

 

$discussIDtrans = $_GET['$comDiscussNo'];

 

if ($discussIDtrans = null) {

$discussID=(int)$_POST['discussID'];

}

 

else {

$discussID = $discussIDtrans;

}

 

$sql = "SELECT * FROM discussion WHERE discussID ='$discussID'";

 

******ETC ETC ETC*******

 

Anyone have any ideas why this isnt working?

 

Cheers

Link to comment
Share on other sites

Thanks guys.

 

i fixed the if statement and using an alert box narrowed the problem down to the get: although the correct variable content is shown in the URL it is not reaching the page: $_GET['comDiscussNo']; has nothing in it (even after changing it like robert suggested).

 

Anyone got any other ideas? Thanks

Link to comment
Share on other sites

Thanks guys.

 

i fixed the if statement and using an alert box narrowed the problem down to the get: although the correct variable content is shown in the URL it is not reaching the page: $_GET['comDiscussNo']; has nothing in it (even after changing it like robert suggested).

 

Anyone got any other ideas? Thanks

 

 

...but this is also strange because even if $_GET['comDiscussNo']; has nothing in it the if statement:

 

$discussIDtrans = $_GET['comDiscussNo'];

$discussIDpost =(int)$_POST['discussID'];

 

if ($discussIDtrans == null) {

$discussID = $discussIDpost;

}

 

else {

$discussID = $discussIDtrans;

}

 

should just pass it on to the else statement, making $discussID equal to the POST

 

weird...

 

Link to comment
Share on other sites

try change this:

if ($discussIDtrans == null)

 

with this

if(empty($discussIDtrans)){

 

Thanks heaps Robert, that has fixed the problem of $_GET['comDiscussNo']; being null.

 

But any suggestions on why the $_GET isnt working?

 

Cheers again!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.