Jump to content

Sessions problem


Suchy

Recommended Posts

I hava a session variable that holds an int passed from a previous page, the new page looks like:

session_start();
session_register ("new_id");
$id = $_GET['id']; // passed from previous page
$_SESSION['new_id'] = $id;

 

Then on this page I have a submit form

if(in("submit")) {
...
session_start(); 
$_SESSION['new_id'] = $temp ; 
$query = "SELECT * FROM names WHERE id = '$new_id' ";
...

 

When I press the submit button the session inside the if(in("submit")) function is not working?

 

What is wrong with my code, and how to fix it?

Link to comment
Share on other sites

Can you post the rest of your script?

 

I don't understand your description of what your code is supposed to do either.

 

And please describe in detail what "the if(in("submit")) function is not working" looks like.  What do you see on the screen?  What did you expect to see?

Link to comment
Share on other sites

I use this function anytime I have a form, since I can have multiple forms with multiple id (ex. id="submit" , then a second form id="update" then third id="delete"...)

and then I can have multiple functions ex:


if(in("update"))
{    
 $id = $_POST['id'];
 $contacted = $_POST['contacted'];
 $done = $_POST['done'];
 $paid = $_POST['paid'];
 $jobnotes = mysql_real_escape_string($_POST['jobnotes']);

 $query = "UPDATE entries SET contacted = '$contacted' , done = '$done' , paid = '$paid' , jobnotes = '$jobnotes' WHERE id = '$id' ";

 $result = mysql_query($query);
} 

///

if(in("Delete"))
{  
 $id = $_POST['id'];
 $query = "DELETE FROM entries WHERE id = '$id'";
 $result = mysql_query($query);
} 

 

These are just examples from previous sites.

 

 

 

The function that I am talking about is:

if(in("submit"))
{    

 session_start(); 
 $_SESSION['new_id'] = $xxx ; 

$query = "SELECT * FROM photo WHERE id = '$new_id' ";
$result = mysql_query($query);
$entriesResults = getRows($result);
}

 

No what I suposed to ge is the picture that has that id.

 

and then use the $new_id in <img src=" "> tag

 

 

 

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.