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.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with online order form i am making

    Hi guys,

    Im am developing a online ordering form for my web hosting company, major problem i am havinf is the way my if statements are working, im pretty new to this and really need some help, you guys will probally spot it instantly.

    Heres php code:

    PHP Code:
    <?php
    //Take customers details

    // Personal Details
    $f_name $_POST['f_name'];
    $s_name $_POST['s_name'];
    $email $_POST['email'];
    $c_email $_POST['c_email'];
    $address $_POST['address'];
    $post_code $_POST['post_code'];

    //Hosting Details
    $hosting_type $_POST['hosting_type'];
    $length_hosting $_POST['length_hosting'];
    $domain $_POST['domain'];
    $hosting_period "";

    //Payment Details
    $payment $_POST['payment'];
    $bill "";

    //Errors
    if ($f_name == "")
       echo 
    "<font color='#FF0000'>You must enter a first name!</font>";
    if (
    $s_name == "")
       echo 
    "<font color='#FF0000'>You must enter a surname!</font>";
    if (
    $email == "")
       echo 
    "<font color='#FF0000'>You must enter a email!</font>"
    if (
    $c_email == "")
       echo 
    "<font color='#FF0000'>You must confirm your email!</font>";  
    if (
    $address == "")
       echo 
    "<font color='#FF0000'>You must enter your address</font>"
    if (
    $post_code == "")
       echo 
    "<font color='#FF0000'>You must enter a post/zip code!</font>"
    if (
    $hosting_type == "")
       echo 
    "<font color='#FF0000'>You must choose a hosting type!</font>";
    if (
    $domain == "")
       echo 
    "<font color='#FF0000'>You must enter a domain!</font>"
    if (
    $paypal == "")
       echo 
    "<font color='#FF0000'>You must choose a payment type!</font>";
    if (
    $jensleypay == "")
       echo 
    "<font color='#FF0000'>You must choose a payment type!</font>"
    else
       echo 
    "<font color='FF0000'>All information is complete and checked!</font>";
    exit;

    //Calculate Costs for package
    if ($length_hosting == 'month') ($hosting_period == '1 Month');
    if (
    $length_hosting == 'year') ($hosting_period == '1 Year');
    if (
    $length_hosting == 'month' ($hosting_type == 'starter' ($bill == '0.99')));
    if (
    $length_hosting == 'month' ($hosting_type == 'expert' ($bill == '2.99')));
    if (
    $length_hosting == 'year' ($hosting_type == 'starter' ($bill == '10.99')));
    if (
    $length_hosting == 'year' ($hosting_type == 'expert' ($bill == '34.99')));

    //Now make custom order page with user submitted information
    echo "Thanks for your order $f_name $s_name","<br>";
    echo 
    "You have chosen the $hosting type package for $hosting_period","<br>"
    echo 
    "Your total bill is  $bill";
    if (
    $payment == 'paypal')
       echo 
    "You have chosen to use $payment </br>","Currently our paypal automated system is down,</br>" "Please send the payment via paypals send money option to the account of sales@thehosters.co.uk<br> with the following information: <br> Name: <br> Email <br> Domain <br>";
    if (
    $payment == 'jensleypay')
       echo 
    "You have chosen to use $payment</br>","Please visit <a href='credit.php'>Here</a> to make your payment";
    else
       echo 
    "<font color='#FF0000'>Error with payment selection, please see <a href='support.php'>Support</a> for more help";
    it isnt finished yet i am also going to get the form data to go to my email account so i can keep a record.

    Many Thanks in advance

    Glen

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    you need a starting if to use the else statement you are trying to use

    PHP Code:
    <?php 
    //Take customers details 

    // Personal Details 
    $f_name $_POST['f_name']; 
    $s_name $_POST['s_name']; 
    $email $_POST['email']; 
    $c_email $_POST['c_email']; 
    $address $_POST['address']; 
    $post_code $_POST['post_code']; 

    //Hosting Details 
    $hosting_type $_POST['hosting_type']; 
    $length_hosting $_POST['length_hosting']; 
    $domain $_POST['domain']; 
    $hosting_period ""

    //Payment Details 
    $payment $_POST['payment']; 
    $bill ""

    //Errors
    if(empty($f_name) || empty($s_name) || empty($email) || empty($c_email) || empty($address) || empty($post_code) || empty($hosting_type) || empty($domain) || empty($paypal) || empty($jensleypay)){
        if (
    $f_name == ""){
            echo 
    "<font color='#FF0000'>You must enter a first name!</font>"
           }
        if (
    $s_name == ""){
            echo 
    "<font color='#FF0000'>You must enter a surname!</font>"
        }
        if (
    $email == ""){
            echo 
    "<font color='#FF0000'>You must enter a email!</font>";  
        }
        if (
    $c_email == ""){
            echo 
    "<font color='#FF0000'>You must confirm your email!</font>";   
        }
        if (
    $address == ""){
            echo 
    "<font color='#FF0000'>You must enter your address</font>";  
        }
        if (
    $post_code == ""){
            echo 
    "<font color='#FF0000'>You must enter a post/zip code!</font>";  
        }
        if (
    $hosting_type == ""){ 
            echo 
    "<font color='#FF0000'>You must choose a hosting type!</font>"
        }
        if (
    $domain == ""){
            echo 
    "<font color='#FF0000'>You must enter a domain!</font>";  
        }
        if (
    $paypal == ""){
               echo 
    "<font color='#FF0000'>You must choose a payment type!</font>"
        }
        if (
    $jensleypay == ""){
               echo 
    "<font color='#FF0000'>You must choose a payment type!</font>";
        }
    exit; 
    }else{
       echo 
    "<font color='FF0000'>All information is complete and checked!</font>"
    }


    //Calculate Costs for package 
    if ($length_hosting == 'month') ($hosting_period == '1 Month'); 
    if (
    $length_hosting == 'year') ($hosting_period == '1 Year'); 
    if (
    $length_hosting == 'month' ($hosting_type == 'starter' ($bill == '0.99'))); 
    if (
    $length_hosting == 'month' ($hosting_type == 'expert' ($bill == '2.99'))); 
    if (
    $length_hosting == 'year' ($hosting_type == 'starter' ($bill == '10.99'))); 
    if (
    $length_hosting == 'year' ($hosting_type == 'expert' ($bill == '34.99'))); 

    //Now make custom order page with user submitted information 
    echo "Thanks for your order $f_name $s_name","<br>"
    echo 
    "You have chosen the $hosting type package for $hosting_period","<br>";  
    echo 
    "Your total bill is £ $bill"
    if (
    $payment == 'paypal'
       echo 
    "You have chosen to use $payment </br>","Currently our paypal automated system is down,</br>" "Please send the payment via paypals send money option to the account of sales@thehosters.co.uk<br> with the following information: <br> Name: <br> Email <br> Domain <br>"
    if (
    $payment == 'jensleypay'
       echo 
    "You have chosen to use $payment</br>","Please visit <a href='credit.php'>Here</a> to make your payment"
    else 
       echo 
    "<font color='#FF0000'>Error with payment selection, please see <a href='support.php'>Support</a> for more help";

  • #3
    New Coder
    Join Date
    Oct 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply!

    Ok i have fixed what you had said, now im getting the following error:

    Code:
    Parse error: syntax error, unexpected '(' in /home/sites/thehosters.co.uk/public_html/forms/order_process.php on line 63
    PHP Code:
    //Calculate Costs for package  
    if ($length_hosting == 'month') ($hosting_period == '1 Month');  
    if (
    $length_hosting == 'year') ($hosting_period == '1 Year');  
    *** 
    LINE63 *** if ($length_hosting == 'month' ($hosting_type == 'starter' ($bill == '0.99')));  
    if (
    $length_hosting == 'month' ($hosting_type == 'expert' ($bill == '2.99')));  
    if (
    $length_hosting == 'year' ($hosting_type == 'starter' ($bill == '10.99')));  
    if (
    $length_hosting == 'year' ($hosting_type == 'expert' ($bill == '34.99'))); 
    I beleive i am coding this wrong with my ) but im not sure where to place these to get the action i need, can anyone else suggest a better way to code this?

    Many Thanks

    Glen

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    if ($length_hosting == 'month') ($hosting_period == '1 Month');
    What are you trying to accomplish with this statement? Are you trying to say "if the variable $length_hosting is equal to string 'month', then assign the string '1 Month' to variable $hosting_period"? If that is what you are attempting to say, then you have the syntax wrong.

    First, a code block is delimited by {} brackets, not () parenthesis. Second, you don't use double equal signs to assign a value to a variable; use a single equal sign for that. Double equal signs means "is the operator on the left equal to the operator on the right?"

    So the correct syntax would be:
    PHP Code:
    if ($length_hosting == 'month') {
        
    $hosting_period '1 Month';


  • #5
    New Coder
    Join Date
    Oct 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks alot fumigator!

    + rep for both who helped me

    Many Thanks Glen

    EDIT:

    Ok, I have made these changes so far here is the whole script:
    PHP Code:
    <?php  
    //Take customers details  

    // Personal Details  
    $f_name $_POST['f_name'];  
    $s_name $_POST['s_name'];  
    $email $_POST['email'];  
    $c_email $_POST['c_email'];  
    $address $_POST['address'];  
    $post_code $_POST['post_code'];  

    //Hosting Details  
    $hosting_type $_POST['hosting_type'];  
    $length_hosting $_POST['length_hosting'];  
    $domain $_POST['domain'];  
    $hosting_period "";  

    //Payment Details  
    $payment $_POST['payment'];  
    $bill "";  

    //Errors 
    if(empty($f_name) || empty($s_name) || empty($email) || empty($c_email) || empty($address) || empty($post_code) || empty($hosting_type) || empty($domain) || empty($paypal) || empty($jensleypay)){ 
        if (
    $f_name == ""){ 
            echo 
    "<font color='#FF0000'>You must enter a first name!</font>";  
           } 
        if (
    $s_name == ""){ 
            echo 
    "<font color='#FF0000'>You must enter a surname!</font>";  
        } 
        if (
    $email == ""){ 
            echo 
    "<font color='#FF0000'>You must enter a email!</font>";   
        } 
        if (
    $c_email == ""){ 
            echo 
    "<font color='#FF0000'>You must confirm your email!</font>";    
        } 
        if (
    $address == ""){ 
            echo 
    "<font color='#FF0000'>You must enter your address</font>";   
        } 
        if (
    $post_code == ""){ 
            echo 
    "<font color='#FF0000'>You must enter a post/zip code!</font>";   
        } 
        if (
    $hosting_type == ""){  
            echo 
    "<font color='#FF0000'>You must choose a hosting type!</font>";  
        } 
        if (
    $domain == ""){ 
            echo 
    "<font color='#FF0000'>You must enter a domain!</font>";   
        } 
        if (
    $paypal == ""){ 
               echo 
    "<font color='#FF0000'>You must choose a payment type!</font>";  
        } 
        if (
    $jensleypay == ""){ 
               echo 
    "<font color='#FF0000'>You must choose a payment type!</font>"
        } 
    exit;  
    }else{ 
       echo 
    "<font color='FF0000'>All information is complete and checked!</font>";  



    //Calculate Costs for package 
    if ($length_hosting == 'month') { 
        
    $hosting_period '1 Month'
    }
    if (
    $length_hosting == 'year') { 
        
    $hosting_period '1 Year'

    if (
    $length_hosting == 'month') + ($hosting_type == 'starter') { 
        
    $bill '0.99'
    }
    if (
    $length_hosting == 'month') + ($hosting_type == 'expert') { 
        
    $bill '2.99'
    }
    if (
    $length_hosting == 'year') + ($hosting_type == 'starter') { 
        
    $bill '10.99'
    }
    if (
    $length_hosting == 'year') + ($hosting_type == 'expert') { 
        
    $bill '34.99'
    }
      
    //Now make custom order page with user submitted information  
    echo "Thanks for your order $f_name $s_name","<br>";  
    echo 
    "You have chosen the $hosting type package for $hosting_period","<br>";   
    echo 
    "Your total bill is  $bill";  
    if (
    $payment == 'paypal')  
       echo 
    "You have chosen to use $payment </br>","Currently our paypal automated system is down,</br>" "Please send the payment via paypals send money option to the account of sales@thehosters.co.uk<br> with the following information: <br> Name: <br> Email <br> Domain <br>";  
    if (
    $payment == 'jensleypay')  
       echo 
    "You have chosen to use $payment</br>","Please visit <a href='credit.php'>Here</a> to make your payment";  
    else  
       echo 
    "<font color='#FF0000'>Error with payment selection, please see <a href='support.php'>Support</a> for more help"
       
    ?>
    Now on line 67 it is saying that Parse error: syntax error, unexpected '{'

    Im guessing that
    PHP Code:
    if ($length_hosting == 'month') + ($hosting_type == 'starter') { 
        
    $bill '0.99'

    I have coded this wrong somewhere? maybe the ) + ( ??im really confused please help!

    Many Thanks Glen
    Last edited by Hughesy1986; 10-29-2006 at 07:06 AM.

  • #6
    New Coder
    Join Date
    Oct 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you trying to say if the length of hosting is monthly and the type is starter then the cost is $.99?

    You would say "AND" instead of using a + sign.

  • #7
    New Coder
    Join Date
    Oct 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    Yes im thats exactly it.

    Code:
    Parse error: syntax error, unexpected T_LOGICAL_AND
    Is this coded right? do I have to have some kind of brackets around the AND operator?

    PHP Code:
    //Calculate Costs for package 
    if ($length_hosting == 'month') { 
        
    $hosting_period '1 Month'
    }
    if (
    $length_hosting == 'year') { 
        
    $hosting_period '1 Year'

    if (
    $length_hosting == 'month') AND ($hosting_type == 'starter') { 
        
    $bill '0.99'
    }
    if (
    $length_hosting == 'month') AND ($hosting_type == 'expert') { 
        
    $bill '2.99'
    }
    if (
    $length_hosting == 'year') AND ($hosting_type == 'starter') { 
        
    $bill '10.99'
    }
    if (
    $length_hosting == 'year') AND ($hosting_type == 'expert') { 
        
    $bill '34.99'


  • #8
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    you need some elseif()s in there in the place of some of your if()s... and when you do a multi-part if statement (ANDs or ORs) you do not close the parenthasis to the if() to put the AND in...

    try this:

    PHP Code:
    //figure out what the billing period is
    if ($length_hosting == 'month') {  
        
    $hosting_period '1 Month';  
    }
    elseif (
    $length_hosting == 'year') {  
        
    $hosting_period '1 Year';  
    }

    //separate if/else statements for the bill price
    if ($length_hosting == 'month' AND $hosting_type == 'starter') {  
        
    $bill '0.99';  

    elseif (
    $length_hosting == 'month' AND $hosting_type == 'expert') {  
        
    $bill '2.99';  

    elseif (
    $length_hosting == 'year' AND $hosting_type == 'starter') {  
        
    $bill '10.99';  

    elseif (
    $length_hosting == 'year' AND $hosting_type == 'expert') {  
        
    $bill '34.99';  

    Last edited by boeing747fp; 10-29-2006 at 03:05 PM.

  • #9
    New Coder
    Join Date
    Oct 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey thanks for all your help!

    Works fine got some rough around the edges but it works thats the main thing.

    You can view it http://www.thehosters.co.uk/order1.html

    Many Thanks Again

    Glen

  • #10
    New Coder
    Join Date
    Oct 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now that is all working, I am sending the whole data to my email account, using this code

    Code:
    mail('admin@thehosters.co.uk', 'Hosting Signup', 'We have had a new client signup for webhosting<br> $package, $hosting_period, $bill, $payment, $email');
    Im not sure why but none of my variables are being included in the email.

    all im receiving is this

    We have had a new client signup for webhosting<br> $package, $hosting_period, $bill, $payment, $email
    Is it something to do with [ bit? i was reading on the php manual this, but it wasnt making much sense

  • #11
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    The PHP processor will interpret variables imbedded in a string only if you use the double quotes. Otherwise it will treat the variable name as a literal.

    Example:

    PHP Code:
    $hello 'hi there ';
    $world 'earth';
    echo 
    '$hello $world';  //echos string '$hello $world'
    echo "$hello $world";  //echos string 'hi there earth' 
    You don't have to imbed variables in a string; you can concantenate them like this:

    PHP Code:
    $disease1 'worms';
    $disease2 'whooping cough';
    echo 
    'my dog has ' $disease1 ' and my grandma has ' $disease2
    For your specific case I think just using double quotes will get you where you want to go.


  •  

    Posting Permissions

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