Hi, I have the following which is used whenever a users enters information into my database. $title= Clean($_POST[title']); mysql_query("INSERT INTO `table` (title) VALUES ('" . $title. "')") or trigger_error(mysql_error(),E_USER_ERROR); //Find ID number of above so i can use it in the return URL header("Location: process.php?id=ID HERE"); exit(); PHP: What i want to do as indicated above is find the id number of the entry. How would i do that? Cheers, Adam
Assuming that id is a primary key, try: $title= Clean($_POST['title']); $id = ''; mysql_query("INSERT INTO `table` (title) VALUES ('" . $title. "')") or trigger_error(mysql_error(),E_USER_ERROR); //Find ID number of above so i can use it in the return URL $id = mysql_insert_id(); header("Location: process.php?id=$id"); exit(); PHP:
Hi, Cheers for that. I have just tried this and although it works, for some reason it destroys a the users session id. Any ideas why this would happen? Cheers, Adam
When you say 'destroys' what do you mean exactly? Does the session id become the insert id or does it become null? The most likely explanation is probably that you've used $id somewhere else and it's overriding the value. Jon