View Full Version : two problems

09-01-2006, 02:09 PM
i have the data from form.php sent to welcome.php but now i need 2 multiply it,

i tried this yesterday

$tv = {$_POST['tv']};
$x = ($tv*365);
echo "$x";

no result!

2nd problem, can i make sure that nobody can type anything other than numbers into my form fields? like tv is numerical and name is normal text?
if you dont understand either of these please reply ill try get into more specific details

09-01-2006, 02:17 PM
try reading some of the tutorials on this site http://www.tizag.com/phpT/

09-01-2006, 02:32 PM
which part of this is meant to help me, looks practically same as www.w3schools.com
i read up2 files, and no help :(

09-01-2006, 03:07 PM
did you look at the operators page im shure it explains how to multiply

09-01-2006, 03:11 PM
ah thank you very much lol my shift wasnt working and i had

$multiplication = $_POST['tv'] 8 365; //instead off
$multiplication = $_POST['tv'] * 365;

any ideas on the other problem?

09-01-2006, 03:30 PM
feel free to see wat im working on too, its the php challenge found @
my out come from this may be found at http://members.tripod.com/jaysphp/form.php
NOTE: you DO NOT have to enter your own information, it will be emailled to me
but emails will be deleted! without using any correct or incorrect details!

09-01-2006, 03:48 PM
very nice :) hmm let me check the other prob :)

09-01-2006, 03:51 PM
here look at this page http://www.xs4all.nl/~sbpoley/webmatters/formval.html
look at the source and copy the javscript :)

09-01-2006, 03:57 PM
what section are you doing now?

09-01-2006, 04:01 PM
just finished challenge to gonna get cracking on the extra's they dont look to good but its experience with different areas of php so im gonna give it a go

09-01-2006, 04:04 PM
did you look at the link above?
also thnx for voting for me lol

09-01-2006, 04:11 PM
lol yes i did and np you have been very helpfull since i joined and deserve my vote!
heres the link to the javascript used in that page i have no idea where to start on editting it lol

09-01-2006, 04:24 PM
use this code

<script language = "Javascript">
* save the as a .jsfile eg:ageval.js
then include it in the page eg:<script src="jsfile"></script

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var ageDelimiters = "/ ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldage = ageDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIage = 10;

function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
// All characters are numbers.
return true;

function stripCharsInBag(s, bag)
{ var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++)
// Check that current character isn't whitespace.
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
return returnString;

function checkInternationalPhone(strPhone){
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);

function ValidateForm(){
var Phone=document.frmSample.age

if ((age.value==null)||(age.value=="")){
alert("Please Enter your Phone Number")
return false
if (checkInternationalPhone(Phone.value)==false){
alert("Please Enter a Valid Phone Number")
return false
return true


<form name="frmSample" method="post" action="#" onSubmit="return ValidateForm()">
<p>Enter a phone number :
<input type="text" name="age">
<input type="submit" name="Submit" value="Submit">

i have edited for you all you need to do is configure the form to your needs :)

09-01-2006, 04:28 PM
thanks very much, shame i cant double vote for u lol

and the first part of the code goes into the head?

09-01-2006, 04:31 PM
save it as a js file eg: ageval.js
and put this code in the head
<script src="jsfilename"></script>

09-01-2006, 04:32 PM
thanks :)

09-01-2006, 04:35 PM
np got anymore probs just pm me:)