hi all, can anyone help me to resolve this issue.
I have this header scrip
$globe_id=$_GET['globe_id'];
header("location: globe_welcome.php?globe_id=".urlencode($globe_id));
It is not working properly.
When i am posting data through form is is not showing id in address bar.
Its result come like
http://mysite/more/globe_welcome.php?globe_id=
where i am wrong? can any body help me?

Recommended Answers

All 37 Replies

Member Avatar for LastMitch

@raovinesh

I have this header scrip
$globe_id=$_GET['globe_id'];
header("location: globe_welcome.php?globe_id=".urlencode($globe_id));
It is not working properly.

Do you have a session_start();?

I'm a bit confused what you are asking?

Do you want the get the $id

in here:

header("location: globe_welcome.php?globe_id=".urlencode($globe_id));

This is how do get the $id

It should look like this:

header("location: globe_welcome.php?globe_id=<?php echo $globe_id;?>");

Plus can you post a little more code regarding about this. It's hard to understand with 1 line of code.

No i am not working with sessions. It is just a simple work where i wanted to get information from my users in too forms.
When they are filling 1st form they are directed to 2nd form, but problem is that id is not showing at header.

here is other portion of this issue
mysql_query ("INSERT INTO globes (cat1, name) VALUES ('$cat1', '$name')")

or die(mysql_error());

// Get ID from browser

$globe_id=$_GET['globe_id'];
header("location: globe_welcome.php?globe_id=<?php echo $globe_id;?>");

?>

Member Avatar for LastMitch

@raovinesh

No i am not working with sessions. It is just a simple work where i wanted to get information from my users in too forms.
When they are filling 1st form they are directed to 2nd form, but problem is that id is not showing at header

Can you show a bit more code? The 2 line code doesn't help either. It's hard to see what is happening without any full code.

Your code:

header("location: globe_welcome.php?globe_id=".urlencode($globe_id));

looks right since you are trying to used urlencode()

Since you are trying to get a variable into the header and trying to get the $id to work, then there's something wrong with your query that is not selecting the id

Have you try these function:

ob_start() 
ob_end_flush() 
ob_end_clean() 

Can you post the code that is related to a query.

dear nothing is more then this
just i used comnnection with server and used two feilds to post name and cat eilds of form

no i have not tried these you asked from me.

<?php

include_once('config.php');

//post data to server
$globe_id  = $_POST['globe_id'];  
$cat1      = $_POST['cat1'];
$name      = $_POST['name'];



// Put data into table


mysql_query ("INSERT INTO  globes (cat1, name) VALUES ('$cat1', '$name')")

or die(mysql_error()); 

// Get ID from browser

$globe_id=$_GET['globe_id']; 
header("location: globe_welcome.php?globe_id=<?php echo $globe_id;?>");

?>

above is the full code iam using to post data.

Member Avatar for LastMitch

@raovinesh

dear nothing is more then this
just i used comnnection with server and used two feilds to post name and cat eilds of form

I don't want to sound rude but this is all your code?

<?php
mysql_query ("INSERT INTO globes (cat1, name) VALUES ('$cat1', '$name')")

or die(mysql_error());

// Get ID from browser

$globe_id=$_GET['globe_id'];
header("location: globe_welcome.php?globe_id=<?php echo $globe_id;?>");

?>
Member Avatar for LastMitch

@raovinesh

Where is the query to select the $id

You need a query to select the $id

A query looks like this:

$sql = SELECT id FROM globes WHERE name="'$globe_id'";

i am trying to be simple and one thing more i am not a programmer but just trying to learn.

If i am wrong any where please help me to correct it. I am beginner not a programmer

please guide me how i do ? because i am not good in php as i already told u.

Member Avatar for LastMitch

@raovinesh

please guide me how i do ? because i am not good in php

I'm assisting you. So your goal is to get a variable into the header?

So far that code you provided is what you are trying to do.

OK I have couple of questions?

Do you have a database? If yes, is it connected?

Try to test this out and let me know what error:

<?php

include_once('config.php');

//post data to server
if ($_POST){
    $globe_id = $_POST['globe_id'];
        $cat1 = $_POST['cat1'];
        $name = $_POST['name'];

// Put data into table
$query = mysql_query("INSERT INTO globes (globe_id, cat1, name) VALUES ('$globe_id', '$cat1', '$name')") or die (mysql_error());
}

// Get ID from browser
$sql = SELECT id FROM globes WHERE name="'$globe_id'"; 

$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());

$globe_id=$_GET['globe_id'];

header("location: globe_welcome.php?globe_id=".urlencode($globe_id));

echo $globe_id;

?>

Dear where i should put this query? please help me because i am litle bit aware of php.

Member Avatar for LastMitch

@raovinesh

Dear where i should put this query? please help me because i am litle bit aware of php.

I just put the query in the code. Test it out.

I changed all u said but i still showing problems. here is new code

<?php

include_once('config.php');

//post data to server
$globe_id  = $_POST['globe_id'];  
$cat1      = $_POST['cat1'];
$name      = $_POST['name'];



// Put data into table


mysql_query ("INSERT INTO  globes (cat1, name) VALUES ('$cat1', '$name')")

or die(mysql_error()); 

// Get ID from browser

$globe_id=$_GET['globe_id']; 
$sql = SELECT globe_id FROM globes WHERE globe_id="'$globe_id'";

header("location: globe_welcome.php?globe_id=<?php echo $globe_id;?>");


?>

It show this result
Parse error: syntax error, unexpected T_STRING in /home/mysite/public_html/more/friend_post.php on line 22

Member Avatar for LastMitch

@raovinesh

Test out this code:

<?php

include_once('config.php');

//post data to server
if ($_POST){
    $globe_id = $_POST['globe_id'];
        $cat1 = $_POST['cat1'];
        $name = $_POST['name'];

// Put data into table
$query = mysql_query("INSERT INTO globes (globe_id, cat1, name) VALUES ('$globe_id', '$cat1', '$name')") or die (mysql_error());
}

// Get ID from browser
$sql = "SELECT id FROM globes WHERE name='$globe_id'";

$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());

$globe_id=$_GET['globe_id'];

header("location: globe_welcome.php?globe_id=".urlencode($globe_id));

echo $globe_id;

?>

Tell me which line has the error when you test it out.

Dear, it is showing this result
Parse error: syntax error, unexpected T_STRING in /home/mysite/public_html/more/friend_post.php on line 12

Again same issue dear

Member Avatar for LastMitch

@raovinesh

Test this code again:

<?php
include_once('config.php');

//post data to server
if ($_POST){
$globe_id = $_POST['globe_id'];
    $cat1 = $_POST['cat1'];
    $name = $_POST['name'];

// Put data into table
$query = mysql_query("INSERT INTO globes (globe_id, cat1, name) VALUES (NULL, '$cat1', '$name')") or die (mysql_error());
}

// Get ID from browser
$sql = "SELECT id FROM globes WHERE name='$globe_id'";
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
$globe_id=$_GET['globe_id'];
header("location: globe_welcome.php?globe_id=".urlencode($globe_id));
echo $globe_id;
?>

Tell me what error you get. It's getting late. I'm from the States and you are from Pakistan. We are in different time zone!

This code is working dear but again issue of id. Id is not appearing again.

<?php
include_once('config.php');
//post data to server
if ($_POST){
    $globe_id = $_POST['globe_id'];
        $cat1 = $_POST['cat1'];
        $name = $_POST['name'];
// Put data into table
$query = mysql_query("INSERT INTO globes (globe_id, cat1, name) VALUES ('$globe_id', '$cat1', '$name')") or die (mysql_error());
}
// Get ID from browser
$sql = "SELECT globe_id FROM globes WHERE globe_id='$globe_id'";
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
$globe_id=$_GET['globe_id'];
header("location: globe_welcome.php?globe_id=".urlencode($globe_id));
echo $globe_id;
?>

Thank you dear very much for assisting me. And iam replying to u as are posting a new change in script.

Member Avatar for LastMitch

@raovinesh

Test this code again:

<?php
include_once('config.php');
//post data to server
if ($_POST){
$globe_id = $_POST['globe_id'];
$cat1 = $_POST['cat1'];
$name = $_POST['name'];
// Put data into table
$result = mysql_query("INSERT INTO globes (globe_id, cat1, name) VALUES (NULL, '$cat1', '$name')") or die (mysql_error());
}
// Get ID from browser
$sql = "SELECT id FROM globes WHERE name='$globe_id'";
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
$globe_id=$_GET['globe_id'];
header("location: globe_welcome.php?globe_id=".urlencode($globe_id));
echo $globe_id;
?>
Member Avatar for LastMitch

@raovinesh

It's getting late. I gotta go soon I'm from the States **and you are from **Pakistan. We are in different time zone! Just post the error. Either me or someone will help you finish this. If noone helps you then I'll help you tomorrow.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.