Hotel Booking Form
Moderator: General Moderators
Hotel Booking Form
OK heres my situation, am creating a database of hotel bookings that i have received on my site. something very simple, at the moment its entering the contents into my HotelBookings Tble and then emailing me the details. i have a BookingID column which is auto incrementing by 1 (ideally would like it to generate a random 8 digit number but can't seem to get it to do it. anyway. so when the new entry hits the db it adds a value of 1 to the db thus creating my BookingID
ideally before it emails me the details i would like it to get the new BookingID from the DB so i have the BookingID when the mail arrives so i can reference the email against the database?
help
Lee
ideally before it emails me the details i would like it to get the new BookingID from the DB so i have the BookingID when the mail arrives so i can reference the email against the database?
help
Lee
...the code at the moment
heres a cpy of the code i have already
Code: Select all
$recipient = "info@bookings.co.uk";
$subject = "Booking Enquiry Created for ".$_REQUEST['HotelName'].", ".date("d M, Y : H:n");
$body = "
HotelName: $HotelName \n
Booking ID: $_REQUEST[BookingID] \n // this doesn;t work but maybe something like this?
Prefix: $Prefix \n
Firstname: $FirstName \n
Surname: $Surname \n"- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
please use
Code: Select all
tags when posting code.
have a look at [php_man]mysql_insert_id[/php_man].. assuming you are using mysql. As for a "random" 8 digit number, you may need to create your own as the good random generators in php return longer results, or varying length results. You shouldn't use the longer result ones because any substring of 8 digits are quite possible to repeat in a short time later. All the random functions are only pseudo-random generators, so beware.
Now, if you stored all the id's you've ever created in the table, you can make the field "unique", and then you'll get an error when you try to insert a pre-existing one; you will need to analyze the error returned.set auto increment field
the other thing you can do instead of generating a random 8 digit id is to just set your auto_increment field to something like 10000000 then the next insert will be 100000001 and so on.
it will be more predictable but this can be a good and bad thing.
it will be more predictable but this can be a good and bad thing.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
depends on what the number is for.
if it is just an order number then something that is decipherable isn't bad.
if is used as a confrimation number of something dealing with personal data that should be kept protected then you are correct.
It sound's like the poster just wanted some way of keeping clients seperate so the poster knew what reservation belonged to whom.
if it is just an order number then something that is decipherable isn't bad.
if is used as a confrimation number of something dealing with personal data that should be kept protected then you are correct.
It sound's like the poster just wanted some way of keeping clients seperate so the poster knew what reservation belonged to whom.
Cheers
feyd | Please use
how would i call that booking ID from the db and then have it included in the email generated? baring in mine it needs to be the last record just created.
cheers for the help
Lee
feyd | Please use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Thanks for the info, i have decided to go with the auto_increment in mysql...seems like the easier option. just havint problems including the BookingID in the email thats generated by the db. any ideas? this is what it looks like now.Code: Select all
$recipient = "booking@mywebsite.co.uk";
$subject = "Booking Enquiry Created for ".$_REQUEST['HotelName'].", ".date("d M, Y : H:n");
$body = "Booking for: $HotelName \n
Booking ID: $BookingID \n
---Customer Information---
Name: $Prefix $FirstName $Surname
ete etc etccheers for the help
Lee
feyd | Please use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Please use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color][/size]
read my first post in this thread.