Dynadot — .com Registration $8.99

Php Code Help

Spaceship Spaceship
Watch

noj

Account Closed
Impact
0
This is the website issue I am now having problem with when doing it in php.....The webpage is @
http://www.vicomputerguy.com/steel/dsheet2.htm the php code is below......the problem I'm having is that I dont know how to keep a running total while I'm entering infomation,and also to prevent entry of Alpha-numeric characters in each field.


right:.5pt solid black'>Light (60
watts)</td>
<td class=xl41 align=right>60</td>
<td class=xl41 align=right>60</td>
<td class=xl42><input type="Text" name= $light size="7" align=right value=0></td>
<td class=xl43 align=right><?php $lightw = $light * 60?>0</td>
<td class=xl42><input type="Text" name="lightq" size="7" align=right value=0> </td>
<td class=xl44 align=right>0</td>
<td class=xl26> </td>
</tr>
<tr height=12>
<td height=12></td>
<td class=xl25> </td>
<td class=xl45>2</td>
<td colspan=3 class=xl96 style='border-

Thank you!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
the page you linked to does not work.

what do you mean by running total?

and to stop people entering alphanumeric in each field, would will either need to check for the characters on validation (so once the form is sent, either client side with javascript, or server side with php, ideally both). Otherwise, to do it upon entry, you need to use javascript and use the onChange function for the fields.
 
0
•••
I don't see any PHP code in the fragment you provided :-/ :-/
 
0
•••
there is some, but it seems to be echo code, but it seems to also be incorrect.

can you repost, using the tags?
 
0
•••
noj said:
This is the website issue I am now having problem with when doing it in php.....The webpage is @
http://www.vicomputerguy.com/steel/dsheet2.htm the php code is below......the problem I'm having is that I dont know how to keep a running total while I'm entering infomation,and also to prevent entry of Alpha-numeric characters in each field.


right:.5pt solid black'>Light (60
watts)</td>
<td class=xl41 align=right>60</td>
<td class=xl41 align=right>60</td>
<td class=xl42><input type="Text" name= $light size="7" align=right value=0></td>
<td class=xl43 align=right><?php $lightw = $light * 60?>0</td>
<td class=xl42><input type="Text" name="lightq" size="7" align=right value=0> </td>
<td class=xl44 align=right>0</td>
<td class=xl26> </td>
</tr>
<tr height=12>
<td height=12></td>
<td class=xl25> </td>
<td class=xl45>2</td>
<td colspan=3 class=xl96 style='border-

Thank you!

There are only 2 php items in there:-

$light

If the other php code is correct then this variable is not enclosed in php tags so will never be evaluated as PHP

<?php $lightw = $light * 60?>

You are not echoing this out you are simply setting $lightw to be $light x 60. And is light a numerical value as the use of where it was elsewhere suggests otherwise.
 
0
•••
In terms of validation of fields: to check if the field is numerical:
PHP:
is_numeric($str);

is_numeric(1); // true
is_numeric(0.1); // true
is_numeric(namepros); // false

Alternatively, you can use a regex:
PHP:
preg_match("/[^0-9]/", $str);
 
0
•••
TheArbiter said:
In terms of validation of fields: to check if the field is numerical:
PHP:
is_numeric($str);

is_numeric(1); // true
is_numeric(0.1); // true
is_numeric(namepros); // false

Alternatively, you can use a regex:
PHP:
preg_match("/[^0-9]/", $str);

If the variable is numerical his use of it originally would be illegal as it would be passing a variable with a numerical name to the form processor. In PHP numerical variables are invalid (however they can be made to work)
 
0
•••
What do you mean by "...numerical variables are invalid..."?
 
0
•••
Wildhoney said:
What do you mean by "...numerical variables are invalid..."?


You cannot for example have a variable called $1. Variables must start with a letter or an underscore.

Looking at what he has done I can only assume he meant:-

<td class=xl42><input type="Text" name= "light" size="7" align=right value=0></td>

He seems to think you need a $ as part of the name but this is purely an educated guess.
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back