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
https://forums.phpfreaks.com/topic/208006-opening-page-with-get-and-post/
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

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

 

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!

Archived

This topic is now archived and is closed to further replies.

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