Create Sequential number / Text file read-write...

R

Rhonda

Hi

I'm trying to create a sequential order number in simple web-based order
forms, that have no DB back ends. It just emails the order for now.

Is there a simple way to Read a number from a Text File on my web server,
increment it by +1, then re-save/update that text file? There must be.

I have scoured the HTML and JavaScript sites finding nothing.

Any suggestion?

Thank you all.
 
O

Oli Filth

Rhonda said the following on 14/09/2005 18:09:
Hi

I'm trying to create a sequential order number in simple web-based order
forms, that have no DB back ends. It just emails the order for now.

Is there a simple way to Read a number from a Text File on my web server,
increment it by +1, then re-save/update that text file? There must be.

I have scoured the HTML and JavaScript sites finding nothing.

Well, that would be because it has nothing to do with HTML or Javscript.
You need to use server-side stuff, like PHP, ASP, or Perl.
 
J

Jonathan N. Little

Rhonda said:
Thank you.

Rhonda: First don't write your reply *above* what you are replying to,
that is called *top-posting*, a no-no in the group.
That must be a difficult request then.

Nothing difficult all.

Oli is telling you the truth, what you wish reading and writing to your
server cannot be done with either HTML or client-side JavaScript. You
have to use scripting the runs on your server...like PHP, ASP, Perl...
 
R

Rhonda

Jonathan N. Little said:
Rhonda: First don't write your reply *above* what you are replying to,
that is called *top-posting*, a no-no in the group.


Nothing difficult all.


Oli is telling you the truth, what you wish reading and writing to your
server cannot be done with either HTML or client-side JavaScript. You
have to use scripting the runs on your server...like PHP, ASP, Perl...

Ok

I'm looking at various simple PHP counter scripts, that can double for my
unique order number.
 
R

Rhonda

Rhonda said:
Ok

I'm looking at various simple PHP counter scripts, that can double for my
unique order number.
I solved my problem!

How's this look? It works perfect. try it.
-----------------------------------------------
<html> <!-- O R D E R N U M B E R G E N E R A T O R -->
<head>
<title>Order Number generator</title> </head>

<body onload="GenerateOrderNumber(); document.ordnum.ordernumber.value =
GenerateOrderNumber();

document.ordnum.startingdate.value = generateTodaysDate(); " background="">

<form name="ordnum">
<div align="center">
<tr>
<td width="155"><font face="Verdana" size="2">Order
Number:</font></td>
<input maxLength=15 size=15 name="ordernumber" ></font></td>

<td width="155"><font face="Verdana" size="2">Order Date:</font></td>
<input maxLength=15 size=15 name="startingdate"></font></td>
</tr>
</div>
</form>
</body>
</html>

<SCRIPT language="javascript">
function GenerateOrderNumber()
{ tmToday = new Date();
return tmToday.getTime(); }
function generateTodaysDate()
{ var d = new Date();
var startingdate = new String((d.getMonth() + 1) + "/" + d.getDate() +
"/" + d.getFullYear()); return

startingdate; }
</SCRIPT>
 
J

Joel Shepherd

I'm looking at various simple PHP counter scripts, that can double for my
unique order number.
I solved my problem!

How's this look? It works perfect. try it.
-----------------------------------------------
<html> <!-- O R D E R N U M B E R G E N E R A T O R -->
<head>
<title>Order Number generator</title> </head>

<body onload="GenerateOrderNumber(); document.ordnum.ordernumber.value =
GenerateOrderNumber();
[snip]

<SCRIPT language="javascript">
function GenerateOrderNumber()
{ tmToday = new Date();
return tmToday.getTime(); }

Rhonda, I don't mean to discourage you, but it's important to recognize
two short-comings of this approach:
1) Visitors who don't have JavaScript may not be able to place orders.
2) Sooner or later (but certainly sooner than expected) two visitors
will load the page at the same time (according to Date()), and you will
receive more than one order with the same order number.

Now, you may not be concerned about lost orders due to #1, and you may
figure you can use other information (names, addresses, etc.) to deal
with #2: in that case, go well.

However, if you are concerned about either of those problems (or when
the day comes that the pain from either is too much), then you'd be much
better served by using a transactional database to generate sequential
numbers. Your customers wouldn't need to support any special
functionality to place orders, and transactions would guarantee that you
would not generate two identical numbers (or nearly so: there are
certain edge cases).

You might also consider transforming the sequence number somehow, so
that folks can't tell whether you've taken 2 orders in the last month or
2000, just by looking at the order number. Again, you might not care,
but in some cases it's important.

Have fun. Order numbers are less trivial than they appear, especially if
you need a lot of 'em.
 
R

Rhonda

Joel Shepherd said:
I'm looking at various simple PHP counter scripts, that can double for my
unique order number.
I solved my problem!

How's this look? It works perfect. try it.
-----------------------------------------------
<html> <!-- O R D E R N U M B E R G E N E R A T O R -->
<head>
<title>Order Number generator</title> </head>

<body onload="GenerateOrderNumber(); document.ordnum.ordernumber.value =
GenerateOrderNumber();
[snip]

<SCRIPT language="javascript">
function GenerateOrderNumber()
{ tmToday = new Date();
return tmToday.getTime(); }

Rhonda, I don't mean to discourage you, but it's important to recognize
two short-comings of this approach:
1) Visitors who don't have JavaScript may not be able to place orders.
2) Sooner or later (but certainly sooner than expected) two visitors
will load the page at the same time (according to Date()), and you will
receive more than one order with the same order number.

Now, you may not be concerned about lost orders due to #1, and you may
figure you can use other information (names, addresses, etc.) to deal
with #2: in that case, go well.

However, if you are concerned about either of those problems (or when
the day comes that the pain from either is too much), then you'd be much
better served by using a transactional database to generate sequential
numbers. Your customers wouldn't need to support any special
functionality to place orders, and transactions would guarantee that you
would not generate two identical numbers (or nearly so: there are
certain edge cases).

You might also consider transforming the sequence number somehow, so
that folks can't tell whether you've taken 2 orders in the last month or
2000, just by looking at the order number. Again, you might not care,
but in some cases it's important.

Have fun. Order numbers are less trivial than they appear, especially if
you need a lot of 'em.


I know of that shortcoming, but it will suffice until I learn enough about
MySQL to take that step.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top