jfs0479 Posted March 1, 2007 Share Posted March 1, 2007 Hi, I have a registration system on my website but i have encountered one problem. After the users sign up they are taken to another page where it connectes to the mysql db and inserts the data.Then that page also sends out an email saying thanks for registering with their details like the password. This is annoying becasue i have set the ID as an autoassigned integer in the mysql it will generate it automaticaly. What i need is to be able to show the new users what their id will be for their login but becasue it is assigned once its got to the database im not sure how i can attempt this. However im not sure if its possible but i dont know how a system can generate the next number in the sequence and show the people at the same time??? Please help lol! James Quote Link to comment Share on other sites More sharing options...
simcoweb Posted March 1, 2007 Share Posted March 1, 2007 Aren't you using a 'username' and 'password' for the registration? Quote Link to comment Share on other sites More sharing options...
obewan Posted March 1, 2007 Share Posted March 1, 2007 how about this? http://us2.php.net/mysql_insert_id Quote Link to comment Share on other sites More sharing options...
jfs0479 Posted March 1, 2007 Author Share Posted March 1, 2007 im not favouring the username approach really but it is an option but yes i do have a password becasue curerently in the processing page i use the $_POST["password1"]; so that is fine to send to the users but the int isnt generated until its in the database if im right. So im strugggling to find a way round it to see if there is a way of displaying the number otherwise i will have to use the username feature In response to your reply obewan this just shows the previous entry i think and your depending on users to enter the next one up but can you trust them to do that??? James Quote Link to comment Share on other sites More sharing options...
craygo Posted March 1, 2007 Share Posted March 1, 2007 once you insert the data you have to query it again to get the last record inserted try this after the insert <?php $sql = "SELECT * FROM tablename ORDER BY id DESC LIMIT 1"; ?> This will get you the last record inserted Ray Quote Link to comment Share on other sites More sharing options...
jfs0479 Posted March 1, 2007 Author Share Posted March 1, 2007 ok great thanks will do! Quote Link to comment Share on other sites More sharing options...
Barand Posted March 2, 2007 Share Posted March 2, 2007 Go with Obewan's suggestion. Craygo, I suggest you too look at http://www.php.net/mysql_insert_id Quote Link to comment Share on other sites More sharing options...
craygo Posted March 2, 2007 Share Posted March 2, 2007 Nice, see learn something new everyday. Ray Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.