Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: two problems

  1. #1
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts

    two problems

    i have the data from form.php sent to welcome.php but now i need 2 multiply it,

    i tried this yesterday

    PHP Code:
    <?php
    $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
    thanks

  • #2
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try reading some of the tutorials on this site http://www.tizag.com/phpT/

  • #3
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    which part of this is meant to help me, looks practically same as www.w3schools.com
    i read up2 files, and no help

  • #4
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    did you look at the operators page im shure it explains how to multiply

  • #5
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    ah thank you very much lol my shift wasnt working and i had
    PHP Code:
    $multiplication $_POST['tv'8 365//instead off
    $multiplication $_POST['tv'] * 365
    any ideas on the other problem?

  • #6
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    feel free to see wat im working on too, its the php challenge found @
    Code:
    http://en.wikibooks.org/wiki/Web_Design/Dynamic_Websites/PHP_Challenges
    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!

  • #7
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    very nice hmm let me check the other prob

  • #8
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    here look at this page http://www.xs4all.nl/~sbpoley/webmatters/formval.html
    look at the source and copy the javscript

  • #9
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what section are you doing now?

  • #10
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    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

  • #11
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    did you look at the link above?
    also thnx for voting for me lol
    Last edited by googleit; 09-01-2006 at 03:07 PM.

  • #12
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    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
    http://www.xs4all.nl/~sbpoley/webmatters/formval.js

  • #13
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    use this code
    validation
    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){
    s=stripCharsInBag(strPhone,validWorldPhoneChars);
    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")
    		Phone.focus()
    		return false
    	}
    	if (checkInternationalPhone(Phone.value)==false){
    		alert("Please Enter a Valid Phone Number")
    		age.value=""
    		age.focus()
    		return false
    	}
    	return true
     }
    </script>
    form
    Code:
    <form name="frmSample" method="post" action="#" onSubmit="return ValidateForm()">
                    <p>Enter a phone number : 
                      <input type="text" name="age">
                    </p>
                    <p> 
                      <input type="submit" name="Submit" value="Submit">
                    </p>
                  </form>
    i have edited for you all you need to do is configure the form to your needs

  • #14
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    thanks very much, shame i cant double vote for u lol

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

  • #15
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    save it as a js file eg: ageval.js
    and put this code in the head
    Code:
    <script src="jsfilename"></script>


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •