value equals value

Silver-0-surfer

Well-Known Member
Joined
Jan 5, 2008
Messages
317
Hi, I would like to know if its possible to have something like this

<input type="text" name="date" value="02/02/10">
<input type="text" name="time" value="date 23:59:59">

Basically I would like the value from the top field to be in the value of the bottom field as well as the time i inputed. I am not very skillful in this regard (as you can probably see) but if its possible and someone point me in the right direction?

Thanks
 

Venom Rush

Expert Member
Joined
Sep 19, 2008
Messages
1,006
Hi, I would like to know if its possible to have something like this

<input type="text" name="date" value="02/02/10">
<input type="text" name="time" value="date 23:59:59">

Basically I would like the value from the top field to be in the value of the bottom field as well as the time i inputed. I am not very skillful in this regard (as you can probably see) but if its possible and someone point me in the right direction?

Thanks

We're going to need a little more info than that. What language are you using or hoping to achieve this with? What are you trying to achieve with the date time fields?
 

Saajid

Expert Member
Joined
Aug 8, 2008
Messages
4,559
We're going to need a little more info than that. What language are you using or hoping to achieve this with? What are you trying to achieve with the date time fields?

Yip you've given very little info, which is pretty vague. Tell us more...
 

Silver-0-surfer

Well-Known Member
Joined
Jan 5, 2008
Messages
317
Thanks for the response

atm it looks like this

<input type="text" name="db_$D$Users.StartDate" value="@db_$D$Users.StartDate@ @db_$T$Users.StartDate@">

this inserts the data entered into a mysql column that has a type datetime.

"@db_$D$Users.StartDate@" bieng the date

and

"@db_$T$Users.StartDate@" bieng the time

However my users do not want to ( and i can't enforce them to) enter a time so when the users enter the date like 2010-01-01 they get a time of 00:00:00

I want it to be 23:59:59, as this grants them access to the internet for a certain amount of time. so basically they lose a entire day of access.

our developer is a way for a while so the buck ends at me :(

so I was thinking if I add a field

<input type="text" name="date" value=""> where they can enter the date and have this field to add their date to my time

<input type="hidden" name="db_$D$Users.StartDate" value="DATE 23:59:59">

does that make any sense at all?
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
yes it sort of makes sense, but why not change the logic of your system to include the date they signed up instead of excluding it (aka,losing a day) just because the time is 00:00:00?

You could always use JavaScript and push the current time in there (or use server side code to get the current date/time so they dont have to capture it) and work on a 24 hour period instead of checking on a date
 

Silver-0-surfer

Well-Known Member
Joined
Jan 5, 2008
Messages
317
The thing, my bad, its actually the expiry date that is causing trouble for me. so the startdate lets say 2010-01-01 00:00:00 (so they lose a couple of hours, not a biggie) but expiry date 2010-01-15 00:00:00 means they only have 14 days and not 15, which is what my issue is.
 

Saajid

Expert Member
Joined
Aug 8, 2008
Messages
4,559
Woah! Dude! What are you doing?

Why are you doing this sort of thing in the front-end. You are opening yourself up to dangerous SQL Injection attacks.

Don't accept a date/time value from the user. Just accept an integer value - the number of days he needs access for. Then do all the calculations on the backend in your websites scripting language (PHP, C#, Perl, Python, etc).

Get the current date from the server, add the number of days required using the aritmetic functions in the DateTime APIs of your language, and save that to the DB.

Also, remember to parameterise all your SQL queries, to avoid SQL injection attacks. If you gave me the address to your website, I could delete your entire DB after 15 minutes of tinkering.
 

Silver-0-surfer

Well-Known Member
Joined
Jan 5, 2008
Messages
317
Its not really out on the internet, the server only allows access from certain IP's etc. but I can't rewrite the whole thing. Im just looking for a sort of quick-fix until the guy can get back and do his job:/
 

Venom Rush

Expert Member
Joined
Sep 19, 2008
Messages
1,006
Woah! Dude! What are you doing?

Why are you doing this sort of thing in the front-end. You are opening yourself up to dangerous SQL Injection attacks.

Don't accept a date/time value from the user. Just accept an integer value - the number of days he needs access for. Then do all the calculations on the backend in your websites scripting language (PHP, C#, Perl, Python, etc).

Get the current date from the server, add the number of days required using the aritmetic functions in the DateTime APIs of your language, and save that to the DB.

Also, remember to parameterise all your SQL queries, to avoid SQL injection attacks. If you gave me the address to your website, I could delete your entire DB after 15 minutes of tinkering.

If the inputs are being cleaned on page execution then there shouldn't be any problem.

@Silver
What language is it you're using (ASP, PHP, Perl)????
 

Silver-0-surfer

Well-Known Member
Joined
Jan 5, 2008
Messages
317
I'm not too sure what language it is. The files have a .hts extension.

It all good though, I added a perl script that check the datetime field for the users, cuts the first ten chars (2010-01-01) and then updates the db with that + the time I chose.

Thanks
 
Top